How do you center text vertically in HTML?

<htmlelement style="text-align:center;" ...>...</htmlelement>

Where:
-htmlelement IS the HTML element in question.
-... IS other HTML code that you might have

Explanation:
-the STYLE attribute is used to provide inline CSS styling (CSS stands for Cascading Style Sheet, a form of styling in HTML)
-the "text-align" name is the CSS attribute name
-the ":" is the division between the name and value
-the "center" is the CSS attribute value
-the ";" is the mark that signifies the end of the CSS attribute
 
<center> text </center>

Place the rag <center> prior to the first work of text to be centered and then use the close tag </center> to complete the text center.

You could also use the paragraph tag with the align attribute. <p align="center"> ...centered text ... </p>
 
Your best bet is to use CSS; just give it some padding.

<div style="padding-top:100px;">My text here</div>

Padding is really the only way to do this. There's no code to "vertically center" text the way horizontal centering works.
 
Back
Top