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>
輸出:
上面的範例是 。標籤以段落格式顯示資料。 代碼: 輸出: 上面的範例是div 標籤,具有一些CSS 樣式(例如背景顏色)以及一個附加標籤(例如 ) ,這裡 標籤用於上面的 代碼: 輸出: 上面的例子與範例 #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中文網其他相關文章!