HTML5 語意標籤理論與實戰
HTML5 / Node.js 聯合小聚
September 17, 2011
HTML5 / Node.js 聯合小聚
September 17, 2011
鄭伊廷 ( xdite@about.me )
Lead Developer / Manager of Techbang
有人趁我不在家時換掉了
而且他寫的還是爛的 HTML5

總之我得收爛攤子
其實我是被逼的
開始找問題…


Google 的結果很正常,應該是 Yahoo 在發春…
3 個月以後終於有空念 HTML5 spec
就跟你說我是被逼的…
讀了 spec 3 小時以後發現這份 HTML 全部都是錯的
Yahoo 我錯怪你了,原來你照 spec 來..
#1 把 section 當成普通容器元素
<header id="header">
<div class="group">
<!-- logo, ads, search, user_nav -->
</div>
<section>
<!-- web sites link-->
</section>
<section>
<!-- main_nav-->
</section>
</header>
<section id="content">
# ……
</section>
每一份文件的重點(第一段)都是:T 集團網路
<header>
<div> <!-- logo, ads, search, user_nav --> </div>
<section>
<header>T客邦集團網路</header>
<nav class="network">
<a href="http://t17.techbang.com.tw">T17</a>
<a href="http://www.techbang.com.tw">Techbang</a>
<a href="http://digiphoto.techbang.com.tw">Digiphoto</a>
<a href="http://game.techbang.com.tw">打電動</a>
<a href="http://bbking.techbang.com.tw">比比王</a>
</nav>
</section>
<section> <!-- main_nav--> </section>
</header>
Yahoo 才是對的 T_T

The section element represents a generic document or application section …The section element is not a generic container element . When an element is needed for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead.
Section 不是容器

#2 把 header 當成普通容器元素
<header>
<div class="group">
<!-- logo, ads, search, user_nav -->
</div>
<section>
<!-- web sites link-->
</section>
<section>
<!-- main_nav-->
</section>
</header>
#3 將看得到的「列表」元素都包上 nav
<header>
<div class="group">
<!-- logo, ads, search, user_nav -->
<nav id="user-navigation">
<ul>
<li> 登入</li>
<li> 註冊 </li>
<li> 關於本站 </li>
</ul>
</nav>
</div>
<section><!-- web sites link--> </section>
<section> <!-- main_nav--> </section>
</header>
a section of navigation links, either to other pages (site navigation) or to sections on the same page (eg a table of contents for long articles). This is for primary navigation blocks, not just for any group of links.
很恐怖不要看…
重要的內容在第 4 層

殺了我比較快…
工作只好吞下去。但苦主還是我。
區塊整理,大區塊規則必須一致
當然沒那麼簡單…

HTML5 超多眉角
<div class="header">
<h1> SITENAME </h1>
</div>
<div class="wrapper">
<div class="article-header">
<h2> POST TITLE </h2>
</div>
<div class="social-link">
SOCIAL LINKS HERE
</div>
<div class="article-content">
# EDITOR's content here
<h1> First class heading </h1>
<p> content here </p>
<h2> Second class heading </h2>
<p> content here </p>
</div>
</div>
<div class="sidebar">
<div class="section">
<h2> Widget Title </h2>
<div class="widget-content">
WIDGET CONTENT HERE
</div>
</div>
</div>
What HTML5 Semantic Tag do ?
# 省略...
<div class="wrapper">
<article>
<div class="article-header">
<header><h2> POST TITLE </h2></header>
</div>
<div class="social-link">
SOCIAL LINKS HERE
</div>
<div class="article-content">
<section>
# EDITOR's content here
<h1> First class heading </h1>
<p> content here </p>
<h2> Second class heading </h2>
<p> content here </p>
</section>
</div>
</article>
</div>
<div class="sidebar">
<aside class="section">
<h2> Widget Title </h2>
<div class="widget-content">
WIDGET CONTENT HERE
</div>
</aside>
</div>
重點一清二楚!
新手通常不知道如何挑選適當的 TAG
工欲善其事,必先利其器
因為 IE 6,7,8 不支援


http://blog.xdite.net/?p=3071
mailto: jobs@techbang.com.tw
http://bit.ly/xdite-book-1 # Rails 101
http://bit.ly/xdite-book-3 # Essential Rails Patterns
Q & A ?