Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertical Align text in a Label

Tags:

html

css

I have been asked to vertically align the text in the labels for the fields in a form but I don't understand why they are not moving. I have tried putting in-line styles using vertical-align:top; and other attributes like bottom and middle but it doesn't work.

Any ideas?

<dd>    <label class="<?=$email_confirm_class;?>"            style="text-align:right; padding-right:3px">Confirm Email</label>    <input class="text" type="text"            style="border:none;" name="email_confirm"            id="email_confirm" size="18" value="<?=$_POST['email_confirm'];?>"            tabindex="4" />     * </dd> 
like image 966
Ian Avatar asked Oct 12 '09 14:10

Ian


People also ask

How do I center text vertically on a label in Word?

1 Select the text you want to center between the top and bottom margins. 2 On the Page Layout tab, click the Page Setup Dialog Box Launcher. 3 Select the Layout tab. 4 In the Vertical alignment box, click Center 5 In the Apply to box, click Selected text, and then click OK.

How do I vertically align a label in a div?

Answer: Use the CSS line-height property Suppose you have a div element with the height of 50px and you have placed some link inside the div that you want to align vertically center. The simplest way to do it is — just apply the line-height property with value equal to the height of div which is 50px .


1 Answers

You can use flexbox in 2018+:

.label-class {     display: flex;     align-items: center; } 

Browser support: https://caniuse.com/#search=flexbox

like image 96
German Khokhlov Avatar answered Sep 29 '22 10:09

German Khokhlov