To center text in HTML, apply the "text-align: center;" CSS property to the HTML block element ("div," "p" or "span" set to "display: block;") wrapping your content. Some browsers allow the use of "center" HTML tags and the "align" attribute, but these are considered obsolete in the latest HTML specification.Continue Reading
Open your HTML document in a code editor and look for the text you want to center. By working your way up the hierarchy of HTML elements, identify the block element that contains it. Text is usually contained inside a paragraph, or "p," element, but if you want to center multiple paragraphs, then it might be best to apply the style to a parent element, such as a "div" holding all the "p" elements you want to center.
Add ' style="text-align: center;" ' after the name of the HTML wrapping the text you want to center. For example, if you are trying to center text within a paragraph element, the code between the lesser-than and greater-than symbols of the tag should look like ' p style="text-align: center;" '.
Save your HTML document, and open it in a Web browser. If the "text-align" CSS property was applied correctly, the text should be centered within the width of its parent element.