You are here:About>Computing & Technology>Web Design / HTML> HTML and XHTML> XHTML> HTML Tags> The DIV Tag
About.comWeb Design / HTML
Newsletters & RSSEmail to a friendSubmit to Digg

The DIV Tag

From Jennifer Kyrnin,
Your Guide to Web Design / HTML.
FREE Newsletter. Sign Up Now!
Description of the DIV Tag:

The <div> tag in XHTML is a tag that defines logical divisions within the content of a page. What this means is that a <div> tag defines sections of a Web page to make it easier to manage, style, and manipulate. You can use the <div> tag when you want to center a block of content or position a content block on the page. The <div> tag is a very powerful tool for Web developers.

HTML Definition of the DIV Tag:

In order to use the <div> tag you need to know the HTML definition of the <div> tag. Some key tips:

  • The <div> tag is a block-level element
  • The <div> tag can contain nearly any other tag
  • The <div> tag cannot be inside <p> tags
Tips for Using the DIV Tag:
  • The <div> tag is not a replacement <p> tag. The <p> tag is for paragraphs, only, while the <div> tag defines more general divisions within a document. Don't replace <p> tags with <div> tags.
  • It's a good idea to label your <div> tags as you place them in your document. For example, if you're defining the main content area of your site, you should name that DIV tag: "maincontent". <div id="maincontent">
  • It's always a good idea to close your <div> tags as soon as you open them. Then place the contents within the element.
  • If you nest your <div> tags, be sure that you know where your content is going (in other words, which DIV it should be part of).
 All Topics | Email Article | | |
Advertising Info | News & Events | Work at About | SiteMap | Reprints | HelpOur Story | Be a Guide
User Agreement | Ethics Policy | Patent Info. | Privacy Policy©2008 About, Inc., A part of The New York Times Company. All rights reserved.