HTML - <div> tag

  »   HTML  »   HTML Tutorial - Using The Div Tag

The div tag is not more than a container for other tags. Here are some of the div's attributes:

  • id
  • class
  • title
  • style
  • height
  • width

The rest of the attributes are not usually used, their job is taken by the CSS.

Here is an example of using the <div> tag:

html<div id="my_menu" align="right">
	<a href="#">HOME</a> | <a href="#">CONTACT</a> | <a href="#">ABOUT</a>
</div>

<div id="my_content" align="left" bgcolor="white">
	<h4>Title here</h4>
	<p>The div tag is a non-visual (by default) element that can be used to apply additional properties to content contained within it. Unlike the span tag</p>
</div>

Demo

Title here

The div tag is a non-visual (by default) element that can be used to apply additional properties to content contained within it. Unlike the span tag

The div tag is much easier to use than the table tag, so for that, it is recommended to use it as many times as you need.

HTML - The div tag - easy to modify

One of the reasons for which it is easy usable is introducing new info with ease and we will exemplify this to you.

In this example, we have added some new fields to the page exemplified above.

html<div id="my_menu" align="right">
	<a href="#">HOME</a> | 
	<a href="#">CONTACT</a> | 
	<a href="#">ABOUT</a> |
	<a href="#">SITEMAP</a>
</div>

<div id="my_content" align="left" bgcolor="white">
	<h4>HTML title here</h4>
	<p>An HTML tag that is widely used to break apart a Web page into elements, each with its own layout attributes. The SPAN tag is somewhat similar to DIV, except that SPAN defines a small amount of text, whereas DIV defines an entire block of data on the page.</p>
	<h4>Second HTML title here</h4>
	<p>The Div macro wraps content in a div tag with optional class and styles.   The div tag is a non-visual (by default) element that can be used to apply additional properties to content contained within it. Unlike the span tag</p>
</div>

Demo

HTML title here

An HTML tag that is widely used to break apart a Web page into elements, each with its own layout attributes. The SPAN tag is somewhat similar to DIV, except that SPAN defines a small amount of text, whereas DIV defines an entire block of data on the page.

Second HTML title here

The Div macro wraps content in a div tag with optional class and styles. The div tag is a non-visual (by default) element that can be used to apply additional properties to content contained within it. Unlike the span tag