2. Semantics
Why?
• Clean - read / edit / reuse
• More accessible - devices
• Search engine friendly - content / code / understand
What?
• Text-Level Semantics Elements - a / em / strong (inline)
• Structural Semantic Elements - p / h1… / article / header (block)
• Interactive Semantics - detail / summary / command / menu
Semantics web
• data’s common formats and integration
• the data relates to real world objects
3. Extending Semantics
Why? - Limited Html labels and attributes/infinite objects of the world
• Mark up a Object? person/event/review/product/movie
<person> <name>your name<name></person>
• Web’s Data? for script / machines
<div yourData=“data for machine”>visible content</div>
4. Extending Semantics
• custom data attribute
Data-* private for your page or app
<div data-name-alice="fake name">your name</div>
elementNode.dataset.nameAlice(); (firefox/chrome/safari/opera)
• WAI-ARIA?
5. Extending Semantics
Mark up a Object : person/movie /product …
public for your page or app and other machines
• Microformats
• RDFa
• Microdata
• …
6. Microformats
<div class="vcard">
My name is
<span class="fn">Bob Smith</span>,
Here is my home page:
<a href="http://www.example.com" class="url">www.example.com</a>.
</div>
Calss
Designed for humans first and machines second, data formats
http://microformats.org/about
Dom API
document.getElementsByClassName("className")
document.querySelectorAll(".className")
7. RDFa
<div xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Person">
My name is <span property="v:name">Bob Smith</span>,
Here is my homepage:
<a href="http://www.example.com" rel="v:url">www.example.com</a>.
</div>
Bridging the Human and Data Webs
a set of XHTML attributes to augment visual data with machine-readable hints
http://www.w3.org/TR/xhtml-rdfa-primer/
vocabulary & property
Dom API
document.getItemsByType("http://xmlns.com/foaf/0.1/Person");
document.getItemByProperty("foaf:name", "Albert Einstein");
8. RDFa Lite
<p vocab="http://schema.org/" typeof="Person">
My name is<span property="name">Manu Sporny</span>
and you can give me a ring via<span property="telephone">1-800-555-
0155</span>.
<img rel="image" src="http://manu.sporny.org/images/manu.png" />
</p>
schema
http://www.w3.org/2010/02/rdfa/sources/rdfa-lite/#about
9. Microdata
<div itemscope itemtype="http://data-vocabulary.org/Person">
My name is <span itemprop="name">Bob Smith</span>,
Here is my homepage:
<a href="http://www.example.com" itemprop="url">www.example.com</a>.
</div>
allows machine-readable data to be embedded in HTML documents
in an easy-to-write manner
http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html
13. Microdata & Schema
<div itemscope itemtype="http://schema.org/Person">
My name is <span itemprop="name">Bob Smith</span>
Here is my homepage:
<a href="http://www.example.com" itemprop="url">www.example.com</a>.
</div>
Itemscope 声明数据
Itemtype 指定数据类型 http://schema.org/Person http://schema.org/Movie ....
Itemprop 指定数据某个属性
DOM API document.getItems("http://schema.org/Person") opera11.60+
详细文档
http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#the-basic-syntax