- HTML 教程
- HTML - 首頁
- HTML - 路線圖
- HTML - 簡介
- HTML - 歷史與演變
- HTML - 編輯器
- HTML - 基本標籤
- HTML - 元素
- HTML - 屬性
- HTML - 標題
- HTML - 段落
- HTML - 字型
- HTML - 塊
- HTML - 樣式表
- HTML - 格式化
- HTML - 引用
- HTML - 註釋
- HTML - 顏色
- HTML - 圖片
- HTML - 圖片地圖
- HTML - Iframes
- HTML - 短語元素
- HTML - 元標籤
- HTML - 類
- HTML - ID
- HTML - 背景
- HTML 表格
- HTML - 表格
- HTML - 表格標題與說明
- HTML - 表格樣式
- HTML - 表格 Colgroup
- HTML - 巢狀表格
- HTML 列表
- HTML - 列表
- HTML - 無序列表
- HTML - 有序列表
- HTML - 定義列表
- HTML 連結
- HTML - 文字連結
- HTML - 圖片連結
- HTML - 郵件連結
- HTML 顏色名稱與值
- HTML - 顏色名稱
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML 表單
- HTML - 表單
- HTML - 表單屬性
- HTML - 表單控制元件
- HTML - 輸入屬性
- HTML 媒體
- HTML - 影片元素
- HTML - 音訊元素
- HTML - 嵌入多媒體
- HTML 頭部
- HTML - Head 元素
- HTML - 新增 Favicon
- HTML - Javascript
- HTML 佈局
- HTML - 佈局
- HTML - 佈局元素
- HTML - 使用 CSS 進行佈局
- HTML - 響應式設計
- HTML - 符號
- HTML - 表情符號
- HTML - 樣式指南
- HTML 圖形
- HTML - SVG
- HTML - Canvas
- HTML API
- HTML - Geolocation API
- HTML - 拖放 API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web 儲存
- HTML - 伺服器傳送事件
- HTML 雜項
- HTML - 文件物件模型 (DOM)
- HTML - MathML
- HTML - 微資料
- HTML - IndexedDB
- HTML - Web 訊息傳遞
- HTML - Web CORS
- HTML - Web RTC
- HTML 演示
- HTML - 音訊播放器
- HTML - 影片播放器
- HTML - 網頁幻燈片
- HTML 工具
- HTML - Velocity Draw
- HTML - 二維碼
- HTML - Modernizer
- HTML - 驗證
- HTML - 顏色拾取器
- HTML 參考
- HTML - 速查表
- HTML - 標籤參考
- HTML - 屬性參考
- HTML - 事件參考
- HTML - 字型參考
- HTML - ASCII 碼
- ASCII 表格查詢
- HTML - 顏色名稱
- HTML - 實體
- MIME 媒體型別
- HTML - URL 編碼
- 語言 ISO 程式碼
- HTML - 字元編碼
- HTML - 已棄用標籤
- HTML 資源
- HTML - 快速指南
- HTML - 有用資源
- HTML - 顏色程式碼生成器
- HTML - 線上編輯器
HTML - <section> 標籤
HTML <section> 標籤用於在 HTML 文件中表示獨立的、自包含的組合內容。此標籤包含在 HTML5 中。
HTML section 標籤類似於 <article> 標籤。單個 HTML 文件可以有多個 section 元素。當 HTML <section> 元素巢狀時,內部元素表示與外部元素相關的部分。例如,社交媒體帖子上的評論可以是巢狀在表示社交媒體帖子的 section 中的 section 元素。它主要用於論壇帖子、雜誌或報紙版塊、部落格文章、產品卡片等。
語法
<section> ..... </section>
屬性
HTML section 標籤支援 HTML 的全域性 和 事件 屬性。
HTML section 標籤示例
以下示例將說明 section 標籤的用法。在哪裡、何時以及如何使用 section 標籤來建立 section 元素。
使用 section 標籤建立自包含內容
在以下示例中,我們使用 <section> 標籤建立了 2 個自包含內容,它們彼此獨立,也與父級獨立。
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML section tag</title>
</head>
<body>
<!-- Creating section Element -->
<h2>HTML 'section' Element</h2>
<section>
<h3>HTML Tags</h3>
<p>
HTML tags are similar to keywords, which specify
how a web browser will format and display content.
A web browser can differentiate between simple content
and HTML content with the use of tags.
</p>
</section>
<section>
<h3>HTML Attributes</h3>
<p>
An attribute is used to define the characteristics
of an HTML element and is placed inside the element's
opening tag. All attributes are made up of two parts:
a name and a value
</p>
</section>
</body>
</html>
設定 section 元素樣式
考慮以下示例,我們將使用 <section> 標籤並應用 CSS 屬性。
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML section tag</title>
<style>
section {
width: 300px;
height: 150px;
background-color: aquamarine;
border-radius: 10px;
}
section h3,
p {
margin: 10px 10px;
}
</style>
</head>
<body>
<!--create a section element-->
<h2>HTML 'section' Element</h2>
<section>
<h3>HTML Tags</h3>
<p>
HTML tags are similar to keywords, which specify
how a web browser will format and display content.
A web browser can differentiate between simple content
and HTML content with the use of tags.
</p>
</section>
<section>
<h3>HTML Attributes</h3>
<p>
An attribute is used to define the characteristics
of an HTML element and is placed inside the element's
opening tag. All attributes are made up of two parts:
a name and a value
</p>
</section>
</body>
</html>
巢狀的 section 元素
讓我們看看另一種情況,我們將建立一個巢狀的 section 元素。
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML section Tag</title>
<style>
section {
margin: 5px;
border-radius: 10px;
padding: 10px;
border: 2px solid black;
}
p {
margin: 10px;
}
</style>
</head>
<body>
<!--create a section element-->
<h2>HTML 'section' Element</h2>
<section>
<h3>HTML Elements</h3>
<p>
HTML Elements are building block of a web page.
It is used to create component for webpages.
</p>
<section>
<h3>HTML Tags</h3>
<p>
HTML tags are similar to keywords, which specify
how a web browser will format and display content.
A web browser can differentiate between simple content
and HTML content with the use of tags.
</p>
</section>
<section>
<h3>HTML Attributes</h3>
<p>
An attribute is used to define the characteristics
of an HTML element and is placed inside the element's
opening tag. All attributes are made up of two parts:
a name and a value
</p>
</section>
</section>
</body>
</html>
在 section 元素上實現影像
在以下示例中,我們建立巢狀的“section”元素以使用 <section> 標籤表示部落格文章及其評論的自包含內容。
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML section tag</title>
<style>
section img {
width: 200px;
}
</style>
</head>
<body>
<!--create a section element-->
<section>
<h2>Blog post</h2>
<img src="/images/logo.png?v3" alt="Tutorialspoint logo">
<section>
<h2>Comments</h2>
<p>Dman good...</p>
<p>fabulous...!</p>
</section>
</section>
</body>
</html>
支援的瀏覽器
| 標籤 | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| section | 是 6.0 | 是 9.0 | 是 4.0 | 是 5.0 | 是 11.1 |
html_tags_reference.htm
廣告




