Name
div
Synopsis
<div>...</div>
Attributes
Core (id, class, style, title), Internationalization,
Events |
Deprecated attributes
align="center|left|right" |
By marking a section of text as a div and giving it a name using id or class attributes, you are essentially
creating a custom HTML element. In this example, a heading and a
list are enclosed in a div
identified as “sidebar.”
<div id="sidebar"> <h1>List of links</h1> <ul> <li>Resource 1</li> <li>Resource 2</li> <li>Resource 3</li> </ul></div>
Because a div is a
block-level element, its contents will start on a new line (even
text not contained within other block-level elements). Otherwise,
div elements have no inherent
presentation qualities of their own.
The div really shines when
used in conjunction with Cascading Style Sheets. Once you’ve marked
up and named a div, you can apply
styles to all of its contents or treat it as a box that can be
positioned on the page, for instance, to form a new text column. A
div may also be called on by
script, applet, or other processing by user agents.