HTML - <div> 标签

  »   HTML  »   HTML教程 - 使用div标签

div标签不比对其它标签的一个容器更多。下面是一些div的属性:

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

属性的其余部分是通常不使用的,它们的工作取决于CSS。

下面是一个例子使用于 <div> 标签的:

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>这里有标题</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

这里有标题

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

div标签是比表格标签更容易来使用,因为你需要使用它多次,所以它是被推荐的。

HTML - div标签 - 易于修改

它容易使用的一个原因就是轻松地引入新的信息以及我们将给你举例说明这些。

在这个例子中,我们已经添加了一些新域到上述例举的页面。

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>这里有第二个HTML标题</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.

这里有第二个HTML标题

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