Latest web development tutorials

HTML <div> tag

Examples

The document will appear as a blue area:

<div style="color:#0000FF">
<h3>这是一个在 div 元素中的标题。</h3>
<p>这是一个在 div 元素中的文本。</p>
</div>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the <div> tag.


Tag definitions and instructions

<Div> tag defines an HTML document in a region separated by a block or section.

<Div> tags commonly used in combination block-level elements, so to format these elements through CSS.


Tips and Notes

Tip: <div> element often used together with CSS, the page layout is used.

NOTE: By default, the browser typically around <div> element to place a newline character.However, you can change this by using CSS.


Differences between HTML 4.01 and HTML5

HTML5 is not supported align attribute.

In HTML 4.01, align attribute obsolete .


Attributes

属性 描述
align left
right
center
justify
HTML5 不支持。HTML 4.01 已废弃。 规定 <div> 元素中的内容的对齐方式。


Global Properties

<div> tag supports HTML global properties .


Event Properties

<div> tag supports HTML event properties .


related articles

HTML Tutorial: HTML Layout