
早期有些網頁設計師利用框架,也就是 <frame> 元素 (element) 切割區域,每個區域載入不同的 HTML 文件,後來越來越多網頁設計師使用 <div> 設定區域,利用 id 屬性 (attribute) 命名每個不同區域的 <div> 元素,然後用 CSS 設定樣式 (style) ,例如
<html>
<head>
<title>Old Web Structure</title>
<style>
#header, #nav, #main, #footer {
color: white;
}
#header, #footer {
text-align: center;
width: 100%;
}
#header {
background-color: red;
font-size: 36px;
font-weight: bold;
}
#nav {
position: fixed;
top: 40px;
right: 25px;
background-color: blue;
width: 100px;
}
#main {
width: 86%;
background-color: gray;
padding: 20px;
margin: 20px;
}
#footer {
background-color: green;
font-size: 10px;
}
</style>
</head>
<body>
<div id="header">
header
</div>
<div id="nav">
<ul>
<li>nav 1</li>
<li>nav 2</li>
</ul>
</div>
<div id="main">
article
</div>
<div id="footer">
<p>
footer © 2011
</p>
</div>
</body>
</html>
<!-- 《程式語言教學誌》的範例程式
http://pydoing.blogspot.com/
檔名:oldwebstructure.html
功能:示範 HTML 5 標記語言
作者:張凱慶
時間:西元 2011 年 12 月 -->此例中利用 header 表示網頁的標題及描述, nav 表示導覽區塊, main 為主要文章區域, footer 則是置底的版權區域。我們使用 Firefox 瀏覽器 (broswer) 開啟如下

現在 HTML 5 提供語意化的標籤,例如 <header> 、 <nav> 、 <section> 、 <footer> 等,直接在網頁結構中標記該區域,例如
<!DOCTYPE html>
<html>
<head>
<title>HTML 5 DEMO</title>
<style>
header, nav, section, article, footer {
display: block;
}
header, nav, section, article, footer {
color: white;
}
header, footer {
text-align: center;
width: 100%;
}
header {
background-color: red;
font-size: 36px;
font-weight: bold;
}
nav {
position: fixed;
top: 40px;
right: 25px;
background-color: blue;
width: 100px;
}
section {
width: 86%;
background-color: gray;
padding: 20px;
margin: 20px;
}
footer {
background-color: green;
font-size: 10px;
}
</style>
</head>
<body>
<header>
header
</header>
<nav>
<ul>
<li>nav 1</li>
<li>nav 2</li>
</ul>
</nav>
<section>
<article>
article
</article>
</section>
<footer>
<p>
footer © 2011
</p>
</footer>
</body>
</html>
<!-- 《程式語言教學誌》的範例程式
http://pydoing.blogspot.com/
檔名:html5webstructure.html
功能:示範 HTML 5 標記語言
作者:張凱慶
時間:西元 2011 年 12 月 --><header> 為 HTML 5 文件置頂的描述區域, <nav> 為導覽區塊,通常用作側邊欄, <section> 為內容區域,裡頭的段落文章再用 <article> 標記,因此一個 <section> 可以有多個 <article> , <footer> 則是置底的描述區域。
若用 Firefox 開啟,會得到一樣的顯示結果。
由於目前這些新的語意化標籤的樣式設定為行內,因此我們在 CSS 樣式表中把 display 性質設定為 block 。
這些新的語意化標籤用作畫分網頁區域,我們稱之為區域元素 (sections) ,裡頭可包含各類群組元素 (grouping content) 、文字階層元素 (text-level semantics) 、編訂元素 (edits) 、內嵌元素 (embedded content) 、表格元素 (tabular data) 、表單元素 (forms) 、互動式元素 (interactive elements) 等。
| 中英文術語對照 | |
|---|---|
| 元素 | element |
| 屬性 | attribute |
| 樣式 | style |
| 瀏覽器 | broswer |
| 區域元素 | sections |
| 群組元素 | grouping content |
| 文字階層元素 | text-level semantics |
| 編訂元素 | edits |
| 內嵌元素 | embedded content |
| 表格元素 | tabular data |
| 表單元素 | forms |
| 互動式元素 | interactive elements |
您可以繼續參考
基本概念
相關目錄
HTML 5 快速導覽
HTML, CSS 教材
首頁
參考資料
http://www.w3.org/TR/html5-diff/
https://developer.mozilla.org/en/Sections_and_Outlines_of_an_HTML5_document
http://www.microsoft.com/web/post/get-started-using-html5
1 則留言:
不好意思,請問能否再解釋一下note的內容?非常感謝!!
張貼留言