Introduction to HTML: Alignment
You can align text left, right, or center. To do this, you use the attribute align. This attribute can be applied to HEADING tags, PARAGRAPH tags, or DIV tags. The DIV tag makes parts of a page look a certain way, but doesn't change spacing like the <P> tag. Use the <DIV align="center"></DIV> tag in place of the <CENTER></CENTER> tag.
Here are possible combinations for the <P> tag:
- <P align="left"> aligns a paragraph to the left
- <P align="right"> aligns a paragraph to the right
- <P align="center"> centers a paragraph
- <H1 align="left"> aligns a heading to the left
- <H1 align="right"> aligns a heading to the right
- <H1 align="center"> centers a heading
- <DIV align="left"> aligns a DIV area to the left
- <DIV align="right"> aligns a DIV area to the right
- <DIV align="center"> centers a DIV area
This paragraph is an example of align="right".
This paragraph is an example of align="center".
Okay, let's go back to the index.html file and center the <H1> tag (and adjust the alignment of any other text you like).
- Open the index.html file in your text editor.
- After the H1 in the <H1> tag type or paste this attribute:
- align="center"
- Save the file and preview it in your web browser.
Take a look at my file if you want to make sure you're doing this correctly.
Next: Design Tips