Professional Documents
Culture Documents
LECTURE#02
ENGR. MUBBASHIR AYUB
Extending HTML5 — Microdata
Nested items
We can make a property into a nested item by adding itemscope to an
element with itemprop.
<p itemscope>The <span itemprop="name">Salter
Cane</span> drummer is <span itemprop="members"
itemscope><span itemprop="name">Jamie
Freeman</span>.</span></p>
This defines an item with two properties, name and members. The
name is Salter Cane, and the members is a nested item, containing the
property name with the value Jamie Freeman. Note that members doesn’t
have a text value.
Items that aren’t part of other items (i.e., anything with itemscope but
not itemprop, or the child of an element with itemprop) are called top-level
microdata items. The microdata API returns top-level microdata items and
their properties, which includes nested items.
Extending HTML5 — Microdata
Multiple properties
Items can have multiple properties with the same name and different values:
<span itemprop="members" itemscope>The band members are
<span itemprop="name">Chris Askew</span>,
<span itemprop="name">Jeremy Keith</span>,
<span itemprop="name">Jessica Spengler</span> and
<span itemprop="name">Jamie Freeman</span>.</span>
This defines the property name with four values, Chris Askew,
Jeremy Keith, Jessica Spengler and Jamie Freeman.
One element can also have multiple properties multiple itemprop=""names
separated by spaces) with the same value:
<p itemscope><span itemprop="guitar vocals">Chris Askew</span>
is so dreamy.</p>
This defines the properties guitar and vocals, both of which have the
value Chris Askew.
Extending HTML5 — Microdata
Microdata in action
So now that we know how, why we want to use microdata?
One use is adding extra semantics or data that we can manipulate via
JavaScript.
But if we use a vocabulary via itemtype or URL- based itemprop names,
microdata becomes considerably more complex and powerful.
While microdata is machine-readable without needing to know the
vocabulary, using a vocabulary means others can know what our
properties mean.
Well, in effect, using a vocabulary makes microdata a
lightweight API for your content.
If you visited someone’s homepage, wouldn’t it be great if you could add
their contact information to your address book automatically?
Extending HTML5 — Microdata
events
products
reviews
recipes
• THE End