HTML Div Tag - Tutorial Republic

HTML <div> Tag

Topic: HTML5 Tags ReferencePrev|Next

Description

The <div> (short for division) tag is generic container for flow content, which has no default rendering or meaning. The <div> tag is extensively used to define the structural sections of a document and to layout a web page using CSS.

The following table summarizes the usages context and the version history of this tag.

Placement: Block
Content: Block, inline, and text
Start/End Tag: Start tag: required, End tag: required
Version: HTML 3.2, 4, 4.01, 5

Tip: The <div> element is ideal for grouping elements for associating the styles and scripts (using the class or id attributes), since it doesn't convey any meaning about its contents and also doesn't have any default styling or meaning.

Syntax

The basic syntax of the <div> tag is given with:

HTML / XHTML: <div> ... </div>

The example below shows the <div> tag in action.

Example

Try this code » <div class="welcome-box"> <h1>Welcome</h1> <p>Hi, welcome to our website.</p> </div>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <div> tag.

Attribute Value Description
align leftrightcenterjustify Obsolete Aligns the content inside a div element.

Global Attributes

Like all other HTML tags, the <div> tag supports the global attributes in HTML5.

Event Attributes

The <div> tag also supports the event attributes in HTML5.

Browser Compatibility

The <div> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 2+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: HTML Layout, CSS Alignment.

Related tag: <span>.

Previous Page Next Page

Từ khóa » Html5 Tag Div