HOW TO SET TEXT VERTICALLY MIDDLE USING CSS ?

Takeshi Okada

Total Post:89

Points:629
Posted by  Takeshi Okada
 1503  View(s)
Ratings:
Rate this:

Hi Expert!

I have two control within div, one is checkbox and other one is label. I want to set label as vertically middle. I have used vertical-align:middle and text-align:center; but this is not worked.
Please help me!

my code as below

<div>
    <input type="checkbox" id="chk" style="width: 25px; height: 25px; background-color:#E5E5E5;" />
    <label for="chk" id="lblChk">
        Product</label>
</div>

Any suggestion will be appreciated!

Thanks in advance.

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: how to set text vertically middle using css ?

    Hi Takeshi!

    Try this way

    vertical-align:super;

    Your modify code as below

    <div>
        <input type="checkbox" id="chk" style="width: 25px; height: 25px; background-color:#E5E5E5;" />
        <label for="chk" id="lblChk" style="vertical-align:super;">
            Product</label>
    </div>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!