Jump to content

hCard

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Hm2k (talk | contribs) at 12:14, 28 September 2011 (→‎External links: +hcard creator). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.


hCard is a microformat for publishing the contact details (which might be no more than the name) of people, companies, organizations, and places, in (X)HTML, Atom, RSS, or arbitrary XML. The hCard microformat does this using a 1:1 representation of vCard (RFC 2426) properties and values, identified using HTML classes and rel attributes.

It allows parsing tools (for example other websites, or Firefox's Operator extension) to extract the details, and display them, using some other websites or mapping tools, index or search them, or to load them into an address-book program.

In May 2009, Google announced that they would be parsing the hCard, hReview and hProduct microformats, and using them to populate search-result pages.[1] In September 2010 Google announced their intention to surface hCard, hReview information in their local search results.[2] In February 2011, Facebook began using hCard to mark up event venues[3].

Example

Consider the HTML:

<ul>
    <li>Joe Doe</li>
    <li>Jo</li>
    <li>The Example Company</li>
    <li>604-555-1234</li>
    <li><a href="http://example.com/">http://example.com/</a></li>   
</ul>

With microformat markup, that becomes:

<link rel="profile" href="http://microformats.org/profile/hcard">
...
</head>
...
<ul class="vcard">
    <li class="fn">Joe Doe</li>
    <li class="nickname">Jo</li>
    <li class="org">The Example Company</li>
    <li class="tel">604-555-1234</li>
    <li><a class="url" href="http://example.com/">http://example.com/</a></li>
</ul>

Here the formatted name (fn), organization (org), telephone number (tel) and web address (url) have been identified using specific class names; and the whole thing is wrapped in class="vcard" which indicate that the other classes form an hcard, and are not just coincidentally named. If the hCard is for an organisation or venue, the fn and org classes are used on the same element, as in <span class="fn org">Wikipedia</span> or <span class="fn org">Wembley Stadium</span>. Other, optional, hCard classes also exist.

It is now possible for software, for example browser plug-ins, to extract the information, and transfer it to other applications, such as an address book.

Geo and adr

The Geo microformat is a part of the hCard specification, and is often used to include the coordinates of a location within an hCard.

The adr part of hCard can also be used as a stand-alone microformat.

Live example

Here are the Wikimedia Foundation's contact details as of 2010-10-28, as a live hCard:

Wikimedia Foundation Inc.
149 New Montgomery Street, 3rd Floor
San Francisco, CA 94105
USA
Phone: +1-415-839-6885
Email:
Fax: +1-415-882-0495

The mark-up (wrapped for clarity) used is:

<div class="vcard">
    <div class="fn org">Wikimedia Foundation Inc.</div>
    <div class="adr">
        <div class="street-address">149 New Montgomery Street, 3rd Floor</div>
        <div> <span class="locality">San Francisco</span>, <abbr class="region" title="California">CA</abbr> <span class="postal-code">94105</span></div>
        <div class="country-name">USA</div>
    </div>
    <div>Phone: <span class="tel">+1-415-839-6885</span></div>
    <div>Email: <span class="email">info@wikimedia.org</span></div>
    <div>
        <span class="tel"><span class="type">Fax</span>: 
        <span class="value">+1-415-882-0495</span></span>
    </div>
</div>

Note that, in this example, the formal name (fn) and organisation (org) properties are combined on one element, indicating that this is the hCard for an organisation, not a person.

Other attributes

Other commonly used hCard attributes include

  • bday - a person's birth date
  • email
  • honorific-prefix
  • honorific-suffix
  • label - for non-granular addresses
  • logo
  • nickname
  • note - free text
  • photo
  • post-office-box

See also

References

  1. ^ Goel, Kavi (2009-05-12). "Introducing Rich Snippets". Google Webmaster Central Blog. Google. Retrieved 2009-05-25. {{cite web}}: Unknown parameter |coauthors= ignored (|author= suggested) (help)
  2. ^ Blumenthal, Mike (2010-09-22). "Google Announces Full Support for Microformats in Local". Understanding Google Maps. Retrieved 2010-09-30.
  3. ^ Protalinski, Emil (2011-02-18). "Facebook adds hCalendar and hCard microformats to Events". ZDNet. Retrieved 24 March 2011.
  • Allsopp, John (2007). Microformats: Empowering Your Markup for Web 2.0. Berkeley: Friendsof. p. 125. ISBN 1590598148. {{cite book}}: Cite has empty unknown parameter: |coauthors= (help)