JavaScript EditorBest javascript editor debugger     Ajax website 

Main Page

Previous Page
Next Page

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:

Type <center>.

Create the element that you wish to center.

Type </center>.

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


  • 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.

Previous Page
Next Page

JavaScript EditorBest javascript editor debugger     Ajax website