Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

html - Markup for postal addresses

Which HTML5 markup should we use for postal addresses? And which vocabulary could we use for enabling machine-readability?

As an example, the address of W3C’s main office:

W3C/MIT
32 Vassar Street
Room 32-G515
Cambridge, MA 02139 USA

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The address element must only be used if this postal address represents the contact information for "its nearest article or body element ancestor", which, of course, is not the case for all addresses. But if address is used or not, it doesn’t affect the following.

The whole address should be enclosed in a p element, because "an address is also a paragraph".
As addresses should not be translated, the translate attribute should be set to no.

Each line (except the last one) should be followed by a br element, because the line breaks are meaningful (or "part of the content", as the HTML5 spec calls it) in addresses.

Each address part (name, street, city, etc.) can be enclosed in a span element. This is not required, but allows the use of semantic annotations.
Abbreviated address parts can be expanded with the abbr element, which can be useful for users not familiar with the address format (e.g., "What means MA?").

So up to this point, we have:

<p translate="no">
  W3C/MIT<br>
  32 Vassar Street<br>
  Room 32-G515<br>
  Cambridge, <abbr title="Massachusetts">MA</abbr> 02139 USA
</p>

Vocabularies

Schema.org’s PostalAddress type can be used for all address parts except for the room.

The vCard Ontology (which maps vCard to RDF) defines an Address class. There doesn’t seem to be a way to specify the room.

Another Address class is defined in the ISA Programme Location Core Vocabulary. The room can be specified with the locatorName property.

Microformats has h-card (with its p-adr) and h-adr. The room can be specified with p-extended-address.

Using the schema.org vocabulary with RDFa (Lite) as an example:

<p translate="no" typeof="schema:PostalAddress">
  <span property="schema:name">W3C/MIT</span><br>
  <span property="schema:streetAddress">32 Vassar Street</span><br>
  Room 32-G515<br>
  <span property="schema:addressLocality">Cambridge</span>, <abbr title="Massachusetts" property="schema:addressRegion">MA</abbr> <span property="schema:postalCode">02139</span> <abbr property="schema:addressCountry">USA</abbr>
</p>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...