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.
Things You'll Need
- HTML text editor
Launch the HTML text editor and create a new page.
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.
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>
Name the file, save it and use the text editor's Preview feature to view your work on a web browser.
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.
- W3Schools.com: HTML <h1> to <h6> align Attribute
- "Sams Teach Yourself Web Publishing with HTML 4"; Laura Lemay; 2000
- Photo Credit Ciaran Griffin/Lifesize/Getty Images
How to Use a Center Punch
Typically a center punch tool is used to aid in drilling. The impression made by a center punch into wood, plastic or...
Centering in HTML
Centering text or paragraphs in HTML is as easy as using a div tag or centering alignment command. Code centered text and...
How to Center Text in HTML
There are two ways to center text in HTML on a Web page, using an align attribute inside an existing tag or...