English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The HTML <div> tag defines a general container in an HTML document, which is usually used to group elements. This tag is also commonly referred to as the <div> element.
Three <div> tags were created in the document:
!doctype html <html> <head> <meta charset="UTF-8"> <title>HTML5 div tag usage (Basic Tutorial Website oldtoolbag.com)</title> <style> .div_class{color:red} #div_id{color:blue} </style> </head> <body> <div> <h2>The first Div</h2> <p>Text will appear in the Div section of the document</p> </div> <div class="div_class"> <h2>The second Div with class applied</h2> <p>Text will appear in the Div section of the document</p> </div> <div id="div_id"> <h2>The third Div with id applied</h2> <p>Text will appear in the Div section of the document</p> </div> </body> </html>Test to see ‹/›
In this HTML5In the document example, we created three <div> tags. The first <div> tag does not apply any class or ID. The second <div> tag applies a class named div_class to the <div> tag. The third <div> tag applies an ID named div_id to the <div> tag.
IEFirefoxOperaChromeSafari
All mainstream browsers support the <div> tag.
The <div> tag is usually used to group elements together.
The <div> tag defines a section or an area within an HTML document.
The <div> tag is commonly used to group block-level elements, so that they can be formatted using CSS.
Tip:<div> elements are often used with CSS to layout web pages.
Note:By default, browsers usually place a line break before and after the <div> element. However, you can change this situation by using CSS.
HTML5 The align attribute is not supported in.
In HTML 4.01 In, the align attribute is deprecated.
Attribute | Value | Description |
---|---|---|
align | left right center justify | HTML5 Not Supported. HTML 4.01 Deprecated. Specify the alignment of the content within a <div> element. |
Support for <div> tag Global Attributes of HTML.
Support for <div> tag HTML Event Attributes.
HTML Tutorial:HTML Layout