简体   繁体   中英

How do I use Microdata fields correctly?

The process of generating a list of events in a page a bit confusing to me.

In this example is the url supposed to represent the current page or a page you are referring to?

 <div itemscope itemtype="http://data-vocabulary.org/Person">

Would that be different from this example where I assume it literally does refer to the href?

 <a href="http://www.example.com" itemprop="url">www.example.com</a>

Can itemprop="locality" be used on zip codes or other postal codes?

Also, is there a way to specify you are referring to an Event and not a Person?

You definitely seem to have the right idea so far. I have used Schema.org before, for setting up Microdata, and they supply an event property to hook into.

<div itemscope itemtype="http://www.schema.org/Event">

Also, navigate to the Event information page to get a full readout of what properties it has.

It does have the option for a location with itemprop="location" . You can see which Itemscopes you can use location on here . One of the options is PostalAddress which has a some of examples which include using postalCode as a property.

<div itemscope itemtype="http://schema.org/PostalAddress">
 <span itemprop="name">Google Inc.</span>
 P.O. Box<span itemprop="postOfficeBoxNumber">1234</span>
 <span itemprop="addressLocality">Mountain View</span>,
 <span itemprop="addressRegion">CA</span>
 <span itemprop="postalCode">94043</span>
 <span itemprop="addressCountry">United States</span>
</div>

There is also a full tree-view of all of the properties available to hook into.

The value 'locality' refers to the city of a delivery address, so if you want to specify the postal code you can use the attribute postal-code:

<span itemprop="postal-code">99999</span>

Source: http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#names:-the-itemprop-attribute

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM