Div 是定义为 Html 文档的分区的标签。主要用于对块元素进行分组;每当我们在 Html 页面上使用它时,它都会用于 CSS 样式表。该部分也是一个标签;它描述了 Html 文档的每个部分,即在 html 中,网页有页眉、页脚等,称为节。每个功能都会随之而来;该部分的任何一个主体都包含在章节部分中。
以下是 HTML Section 与 Div 之间的前 6 个比较:
让我们在以下几点讨论 HTML Section 与 Div 之间的一些关键区别:
下表总结了 HTML Section 与 Div 之间的比较:
Html Section Tag | Html Div Tag |
The tag defines a section of documents like chapters, headers, footers and body sections. | The tag defines a separate division or sections of the documents. |
tag is use for html5 version. |
|
It is not a generic container and global attributes. | It is a generic container. |
When creating a section in html 5 version, the id should be a unique one, and the class should use it multiple times when it is needed. | When div tag, place any html elements within the tag and cannot use for inside the tag because the paragraph tag will be broken at any point in time. |
Here CSS is not necessary hence it is a structural element used to group together related elements. If. we want to use CSS styles in sections IE 9 browser and some other browsers supported previous IE versions not supported. | Applying CSS styles inside the div tag uses tag, which is used for within inline elements. All browsers will be supported hence no compatibility issue. |
Section tag containing article elements in html | Div tag contains all the elements where the tag should not force to do it. |
内部标签,因为段落标签随时都会被破坏。
所在的所有元素。标签不应强制执行此操作。
以下是Section Tag和Div Tag的示例:
代码:
<html> <body> <section> <h1>Sample</h1> <p>WelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcomeWelcome</p> </section> <section> <h1>First</h1> <p>WelcometomydomainWelcometomydomainWelcometomydomainWelcometomydomainWelcometomydomainWelcometomydomainWelcometomydomainWelcometomydomainWelcometomydomainWelcometomydomainWelcometomydomain</p> </section> </body> </html>
输出:
上面的例子是 。标签以段落格式显示数据。 代码: 输出: 上面的示例适用于带有一些 CSS 样式(如背景颜色)的 div 标签,以及一个附加标签(如 ) ,这里 标签用于上面的 代码: 输出: 上面的例子与示例 #2 – Div 标签
<html>
<body>
<p>Sample.</p>
<div style="background-color:Green">
<h3>Welcome To My Domain</h3>
<p>Welcome To My Domain</p>
</div>
</body>
</html>
示例 #3 – Div 标签
<html>
<head>
<style>
#s{
width:10px;
background: #green;
height:40px;
}
.s1{
width:90px;
font: 60.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size:10px;
font-weight:bold;
}
</style>
</head>
<body>
<marquee><p>Sample.</p></marquee>
<div id="s">
<div class="s1">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">AboutUs</a></li>
<li><a href="#">ContactUs</a></li>
</ul>
</div><!--closing div class for "menu"-->
</div><!--closing div for "container"-->
</body>
</html>
以上是HTML 节与 Div的详细内容。更多信息请关注PHP中文网其他相关文章!