HTML and CSS Reference
modifies the element's horizontal alignment (left, center, or right) on a Web page. To
center an element on a Web page use the attribute align="center" . To right-justify an
element on a Web page, use align="right" . The default alignment is left. The align
attribute can be used with a number of block level elements, including the paragraph
( <p> ) and heading ( <h1> through <h6> ) tags.
A <br /> tag
creates the line
break after the first
Why does my Web page still look the same?
Often, students make changes to a Web page but get frustrated because their browser shows
an older version of the page. The following troubleshooting tips are helpful when you know you
modified your Web page but the changes do not show up in the browser:
1. Make sure you save your page after you make the changes.
2. Verify the location that you are saving your page to—the hard drive, a particular folder.
3. Verify the location that your browser is requesting the page from—the hard drive, a par-
4. Be sure to click the Refresh or Reload button in your browser.
Open your heading3.html file in Notepad. Modify the heading to be centered. Change
the <h1> tag to <h1 align="center"> but do not change the closing </h1> tag. Also
modify the paragraph to be centered on the Web page. Change the <p> tag to
<p align="center"> , but do not change the closing </p> tag. Save your page as
heading4.html and test it in a browser. Your page should look similar to the page
shown in Figure 2.8. You can compare your work with the solution found in the stu-
dent files (Chapter2/heading4.html).
Legacy Alert. You will find many Web pages that use the align attributes to center
block-level elements such as paragraphs and headings. Be aware that the align attribute is
supported in XHTML 1.0 Transitional but is deprecated. In Chapters 3 and 6, you will
learn to use Cascading Style Sheets (CSS) to configure alignment of text on a Web page.