HTML <div> Tag
<div style="background:#F9EECF;width:50%;height:50%;"> Generic content... </div>
The above example demonstrates usage of the
<div> element. In this example I've applied some inline styles in order to see the actual
<div> on the page.
<div> element is a generic container with no particular meaning. It is often used to enclose elements into logical groups, usually with a view to applying styles to the group or specific elements within the group.
The W3C says that the
can be used with .
title attributes to mark up semantics common to a group of consecutive elements
The W3C also says that
authors should view the .
<div> element as an element of last resort, for when no other element is suitable
Prior to HTML5, the
<div> element was widely used for creating containers for specific purposes and having its purpose conveyed using the
class attribute. For example, this method was used to declare the "main" content section, an "article", a "nav" bar, a "header", "footer", etc. However, HTML5 has many elements that are specifically designed for these purposes (such as
<footer>, etc). Therefore, these elements should be used in place of the