HTML <div> tag
Example
A section in a document that will be displayed in green:
<div style="color:#00FF00">
<h3>This is a header</h3>
<p>This is a paragraph.</p>
</div> |
Try it yourself!
|
Definition and Usage
The <div> tag defines a division or a section in an HTML document.
The <div> tag is often used to group block-elements to format them
with styles.
Browser Support
The <div> tag is supported in all major browsers.
Differences Between HTML and XHTML
The "align" attribute of the div element was deprecated
in HTML 4.01, and is not supported in XHTML 1.0
Strict DTD.
Tips and Notes
Tip: The div element is very often used with CSS to layout a web page.
Note: Browsers usually place a line break before and after the div
element.
Optional Attributes
DTD indicates in which DTD the attribute is
allowed. S=Strict, T=Transitional, and F=Frameset.
Attribute |
Value |
Description |
DTD |
align |
left
right
center
justify |
Deprecated. Use styles instead. How to align the text in the div element. |
TF |
Standard Attributes
id, class, title, style, dir, lang, xml:lang |
For a full description, go to Standard
Attributes.
Event Attributes
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup |
For a full description, go to Event Attributes.
|
|
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate is for developers who want to document their knowledge of JavaScript and the HTML DOM.
The XML Certificate is for developers who want to document their knowledge of XML, XML DOM and XSLT.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
The PHP Certificate is for developers who want to document their knowledge of PHP and SQL (MySQL).
|
|