Language References
Specifies a container for grouping HTML elements. | HTML 3.2, 4, 4.01, 5 |
HTML Syntax
<div
align = center | left | right
class = classname
datafld = colname
dataformatas = html | text
datasrc = #id
id = value
style = css properties
title = text
event = script
>
The DIV element encloses a block of content. A DIV is useful for applying alignment and style characteristics to a section of a document that contains multiple elements, rather than having to apply the alignment and styles to each element in the block. Each DIV element starts on a new line.
To enclose an inline section of content, authors can use the SPAN element.
DIV Members
The following example uses a DIV element to apply styles to a group of content. Although the example uses only a single statement of text, a DIV can contain any combination of elements, including images and embedded objects.
<div style="font:bold 14pt arial; background:steelblue; color:beige;
width:75%; padding:30; text-align:center; border:medium ridge">
This area represents a DIV, or a defined section in the document.
Its text is centered, has a background and border, and a defined width.
</div>
This area represents a DIV, or a defined section in the document. Its text is centered, has a background and border, and a defined width.
Note that some versions of older browsers may render the style attributes somewhat differently.
SPAN