HTML Div tutorials

Tutorials and tips

DIV and it's usage

The div element gives structure and context to any block-level content in a document. Unlike some other structureal elements that have very specific cannotations attached to them (the p element, for instance), the author is free to give meaning to each particular div element by virtue of the element's attribute settings and nested content. Each div element becomes a generic block-level container for all content within the required start and end tags.

It is most convenient to use the div element as wrapper for multielement content that is to be governed by a single style sheet rule. For example, if a block of content includes three paragraphs, rather than assign a special font style to each of the p elements, you can wrap all three p elements with a single div element whose style sheet defines the requested font style. Such a style sheet could be defined as an inline style attribute of the div element or assigned via the class or id attribute, depending on the structure of the rest of the document. Div elements are block-level elements. If you need an arbitrary container for inline content, use the span elements, instead.