HTML5 semantic elements
HTML5 Semantic Element
Semantic = meaning.
Semantic Element = Meaning of element.
What is a semantic element?
A semantic element can Clearly describe its meaning to browsers and developers.
Semantic element examples: <div> and <span> - no need to consider content.
Semantic element examples: <form>, <table>, and <img> - clearly defines its content.
No semantic element examples: <div> and <span> - No need to consider the content.
Semantic element examples: <form>, <table> , and <img> - clearly defines its content.
<title> is a typical semantic tag that defines the title of the document.
New semantic elements in HTML5
Many existing websites contain the following HTML code: <div id="nav">, <div class="header">, or <div id="footer">, to indicate navigation Links, headers, and trailers.
HTML5 provides new semantic elements to identify different parts of a Web page:
<header>
<nav>
<section> ;
<article>
<aside>
<figcaption>
<figure>
<footer>
HTML5 <section> Element
<section> tag defines a section (section, section) in the document. Such as chapters, headers, footers, or other parts of the document.
According to W3C HTML5 documentation: section contains a set of content and its title.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <section> <h1>沁園春 雪</h1> <p>北國風(fēng)光, 千里冰封, 萬里雪飄。 望長城內(nèi)外, 惟余茫茫。 大河上下, 頓失滔滔。 山舞銀蛇, 原馳蠟象。 欲與天公誓比高。 須睛日, 看紅裝素裹, 分外妖嬈。 江山如此多嬌, 引無數(shù)英雄競折腰。 昔秦皇漢武, 略疏文采; 唐宗宋祖, 稍遜風(fēng)騷。 一代天驕, 成吉思汗, 只識彎弓射大雕。 俱往矣, 數(shù)風(fēng)流人物, 還看今朝。</p> </section> <section> <h1>我愛這土地</h1> <p>假如我是一只鳥, 我也應(yīng)該用嘶啞的喉嚨歌唱: 這被暴風(fēng)雨所打擊著的土地, 這永遠(yuǎn)洶涌著我們的悲憤的河流, 這無止息地吹刮著的激怒的風(fēng), 和那來自林間的無比溫柔的黎明</p> </section> </body> </html>
HTML5 <article> Element
<article> tag defines independent content. .
<article> Element usage example:
Forum post
Blog post
News story
Comment
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <article> <h1>Internet Explorer 9</h1> <p> Windows Internet Explorer 9(縮寫為 IE9 )在2011年3月14日21:00 發(fā)布。</p> </article> </body> </html>
HTML5 <nav> Element The
<nav> tag defines the portion of the navigation link. The
<nav> element is used to define the navigation link area of ??the page. However, not all links need to be included in the <nav> element!
HTML5 <aside> Element The
<aside> tag defines content outside the main area of ??the page (such as a sidebar).
The content of the aside tag should be related to the content of the main area.
HTML5 <header> element
<header> element describes the head area of ??the document
<header> element Note that it is used to define the introductory display area of ??the content.
You can use multiple <header> elements in the page.
HTML5 <footer> Element
The<footer> element describes the bottom area of ??the document.
The<footer> element should contain its containing element
A footer usually contains the author of the document , copyright information, linked terms of use, contact information, etc.
You can use multiple <footer> elements in the document.
HTML5 <figure> and <figcaption> elements
The<figure> tag specifies independent stream content (images, charts, photos, code, etc.). The content of the
<figure> element should be related to the main content, but should have no impact on document flow if removed.
<figcaption> tag defines the title of the <figure> element.
The<figcaption> element should be placed as the first or last child element of the "figure" element. .
Write a comprehensive example and you will understand after comparing it:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>語義元素</title> </head> <body> <!--結(jié)構(gòu)元素--> <header>頭部</header> <section>表示一個段落:用于區(qū)域的章節(jié)表述</section> <footer>區(qū)域的頁腳部分</footer> <nav>菜單 導(dǎo)航</nav> <article>表示文章的主體內(nèi)容</article> <!--塊級元素 用于區(qū)域的劃分--> <aside></aside> <figure> <figcaption></figcaption> </figure> <code>表示一段代碼</code> <dialog>表示對話 <dt>說話的人</dt><dd>內(nèi)容</dd> </dialog> <!--語義元素--> <mtter>一定范圍的數(shù)值</mtter> <time></time> <progress>進(jìn)度條</progress> <video>視頻</video> <audio>音頻</audio> <!--交互元素--> <details>一段具體內(nèi)容 通過某個方法顯示</details> <datagrid>用來控制客戶端數(shù)據(jù)顯示</datagrid> <menu>動態(tài)交互菜單</menu> <command>命名</command> <!--顯示文章案例--> <article> <header> <h1>HTML head 頭部分的標(biāo)簽</h1> <time>2015年12月12日</time> </header> <p>HTML head 頭部分的標(biāo)簽、元素有很多,涉及到瀏覽器對網(wǎng)頁的渲染,SEO等等,而各個瀏覽器內(nèi)核以及各個國內(nèi)瀏覽器廠商都有些自己的標(biāo)簽元素,這就造成了很多差異性。移動互聯(lián)網(wǎng)時代,head 頭部結(jié)構(gòu),移動端的meta 元素,顯得更為重要。了解每個標(biāo)簽的意義,寫出滿足自己需求的head 頭標(biāo)簽,是本文的目的。本篇以一絲的文章為基礎(chǔ),進(jìn)行擴(kuò)展總結(jié)介紹常用的head中各個標(biāo)簽、元素的意義以及使用場景。</p> <footer> <p>http://www.baidu.com</p> </footer> </article> <!--評論--> <section> <h2>評論</h2> <article> <header> <h3>張帥</h3> <p><time pubdata datatime="2013-09-23 10:00 - 11:00">一小時前</time></p> </header> <p>評論內(nèi)容</p> </article> <article> <header> <h3>張帥</h3> <p><time pubdata datatime="2013-09-23 10:00 - 11:00">一小時前</time></p> </header> <p>評論內(nèi)容</p> </article> </section> </body> </html>