Centering Elements on a Page


The center tag is one of those elements that has been deprecated but not forgotten. When centering with CSS seems like too much of a hassle, many continue to use the center tag. It remains well supported and can be used with virtually any element on your page.

To center elements on a page:

1.

Type <center>.

2.

Create the element that you wish to center.

3.

Type </center>.

Figure 4.22. The center element acts like a div element with the align attribute set to center.


Tips

  • The center element is nothing more than an abbreviation of <div align="center"> ... </div>.

    Figure 4.23. The center element continues to be well supported.

  • For more details on dividing your document into sections that you can then align, consult Breaking up a Page into Divisions on page 64.

  • For more on the (deprecated) align attribute, in particular with paragraphs and headers, see the last tips on pages 6162.

  • If you use the center element, you should make sure to also declare a transitional DOCTYPE (see page 56).

  • For information on using styles to center text, consult Aligning Text on page 165.

  • For information on aligning images with text, consult Aligning Images on page 100.





HTML, XHTML, & CSS(c) Visual QuickStart Guide
HTML, XHTML, and CSS, Sixth Edition
ISBN: 0321430840
EAN: 2147483647
Year: 2004
Pages: 340

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net