How to Center Text Using HTML Codes
As you design and build websites, you may want know how to center text using HyperText Markup Language (HTML)--the code used to build webpages. This format is ideal if you need to present content in a way that is more noticeable or if you need to style the targeted text so that it fits better within the other elements of the page. By using an attribute within an HTML tag, you can easily center the text of your choice.
Instructions
-
-
1
Launch the HTML text editor and create a new page.
-
2
Type in the text that that you want centered in between the "<body></body>" tags or in the design view of the text editor workspace.
-
-
3
Enter the "align" attribute in the HTML tag that surrounds your text, such as the "<h1>" tag, and set this to the "center" alignment as follows:
<h1 align="center">Centered Heading Text</h1>
-
4
Name the file, save it and use the text editor's Preview feature to view your work on a web browser.
-
1
Tips & Warnings
If the HTML file has a Cascading Style Sheet (CSS) attached, you may not be able to center text with HTML because the CSS may already have an alignment rule in place.