Description of the DIV Element:
DIV Element as of HTML5
DIV element has not changed a lot in HTML5, it is now an element that defines generic containers within the content of a page. It is an element that is not meant to represent anything semantically. But you can use
title attributes to give your
DIV element some semantic meaning.
DIV Element in HTML 4
DIV element in HTML 4 defines sections of a web page to make it easier to manage, style, and manipulate. You can use the
DIV element when you want to center a block of content or position a content block on the page.
You can do these same things in HTML5, but you are encouraged to use more semantically relevant elements before you use the
HTML Definition of the DIV Tag:
In order to use the
DIV element you need to know the HTML definition of the
DIV element. Some key tips for using the
DIV element correctly include:
DIVelement is a block-level element
DIVelement can contain nearly any other tag
- In HTML 4, the
DIVelement cannot be inside another block-level element, like a
- In HTML5 the
DIVelement can be found inside any element that can contain flow elements, such as other
BLOCKQUOTE, sectioning elements, and tables.
Using the DIV Element:
- You should always use the
DIVelement as a last resort after using other sectioning elements. Read this article to learn how to use sectioning elements correctly.
DIVelement is not a replacement
Pelement is for paragraphs, only, while the
DIVelement defines more sections within a document. Don't replace
- It's a good idea to label your
DIVelements as you place them in your document. For example, if you're defining the main content area of your site, you should name that
DIVelement with the
- It's always a good idea to close your
DIVelements as soon as you open them. Then place the contents within the element.
- If you nest your
DIVelements, be sure that you know where your content is going (in other words, which
DIVelement it should be part of).