HTML <center> tag

The <center> tag is used to center content within its containing element.

NOTE: If some content you try to center is not within a containing element, then it's containing element will automatically be the webpage itself in which case the content will be centered on the page.

NOTE: This tag is deprecated.

Standard attributes

class, dir, id, lang, style, title

For more information on standard attributes, check out our HTML standard attributes reference page.

Event attributes

onclick, ondblclick, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onkeydown, onkeypress, onkeyup

For more information on event attributes, check out our HTML event attributes reference page.

Example

This text is not centered <center>This text IS centered</center> <div> <p>The image in this div element will be centered</p> <center> </img src="/images/swan.jpg" alt="Swan" /> </center> </div>
Output:
This text is not centered
This text IS centered

The image in this div element will be centered

Swan

Tips & notes

The <center> tag is deprecated. CSS should be used instead.

Don't get overexcited about the whole centering concept. You should center content only when you really need to like to place emphasis on some text or an image or to center the entire content container of a webpage as part of the style of a website. Centering should be practiced carefully and efficiently.

Web Reference
  1. CSS reference
  2. RSS reference
  3. HTML reference


© Copyright 2011-2012 Landofcode.com
Terms of use | Privacy policy | Copyright information | Make a donation