hCard 1.0

hCard is a simple, open format for publishing people, companies, organizations on the web, using a 1:1 representation of vCard (RFC2426) properties and values in HTML. hCard is one of several open microformat standards suitable for embedding data in HTML/HTML5, and Atom/RSS/XHTML or other XML.

Background

In addition, many bloggers identify themselves by name and discuss their friends and family. With just a tad bit of structure, bloggers can discuss people in their blog(s) in such a way that spiders and other aggregators can retrieve this information, automatically convert them to vCards, and use them in any vCard application or service.

This specification introduces the hCard format, which uses a 1:1 representation of the properties and values of the aforementioned vCard standard, in semantic HTML. Bloggers can both embed hCards directly in their web pages, and style them with CSS to make them appear as desired. In addition, hCard enables applications to retrieve information directly from web pages without having to reference a separate file.

Use the hCard creator and copy the HTML code it generates to your blog or website to publish your contact info.

Conformance

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Format

In General

The basic format of hCard is to use vCard object/property names in lower-case for class names, and to map the nesting of vCard objects directly into nested HTML elements.

Root Class Name

The root class name for an hCard is "vcard". An element with a class name of "vcard" is itself called an hCard.

Properties and Sub-properties

The properties of an hCard are represented by elements inside the hCard. Elements with class names of the listed properties represent the values of those properties. Some properties have sub-properties, and those are represented by elements inside the elements for properties.

Property Notes

1. ^: The 'n' property is OPTIONAL if any implied 'n' optimization rules are in effect.2. ^: tel - Authors MAY follow the E.123 standard for writing values of telephone numbers. Letter values (e.g. +1-555-FORMATS) MUST be converted to numbers. Use an abbr to display letters and provide a numerical value simultaneously, e.g. <abbr title="+15553676287">+1-555-FORMATS</abbr>.3. ^: tz - timezones are indicated with the timezone offset, e.g. PST (<span class="tz">-08:00</span>).

Singular vs. Plural Properties

Singular properties: 'fn', 'n', 'bday', 'tz', 'geo', 'sort-string', 'uid', 'class', 'rev'. For properties which are singular, the first descendant element with that class SHOULD take effect, any others being ignored.

All other properties MAY be plural. Each class instance of such properties creates a new instance of that property.

Human vs. Machine readable

The human visible text contents of an element for a property represents the value of that property, with a few exceptions:

If an <abbr> element is used for a property, then the 'title' attribute (if present) of the <abbr> element is the value of the property, instead of the contents of the element, which instead provide a more human presentable version of the value.

If an <a> element is used for one or more properties, it MUST be treated as follows:

For the 'photo' property and any other property that takes a URL as its value, the href="..." attribute provides the property value.

For other properties, the element's content is the value of the property.

If an <img> element is used for one or more properties, it MUST be treated as follows:

For the 'photo' property and any other property that takes a URL as its value, the src="..." attribute provides the property value.

For other properties, the <img> element's 'alt' attribute is the value of the property.

If an <object> element is used for one or more properties, it MUST be treated as follows:

For the 'photo' property and any other property that takes a URL as its value, the data="..." attribute provides the property value.

For other properties, the element's content is the value of the property.

Value excerpting

Sometimes only part of an element which is the equivalent for a property is used for the value of the property. This typically occurs when a property has a subtype, like 'tel'. For this purpose, the special class name "value" is used to excerpt out the subset of the element that is the value of the property. E.g. here is an hCard fragment for marking up a home phone number:

No change in display, but the parsed hCard property value then becomes in vCard:

vCard:

TEL;TYPE=HOME:+14155551212

Property Exceptions

vCard has several properties which either do not make sense on, or are already implied within the context of a web page. This section explains what to (not) do with them.

vCard's NAME, PROFILE, SOURCE, PRODID, VERSION properties are defined in Sections 2.1.2, 2.1.3, 2.1.4, 3.6.3, 3.6.9 of RFC2426. Content publishers MUST NOT use these properties in their hCards, and as such, hCard consumers/parsers MUST IGNORE these properties if they are found within an hCard. Instead. hCard to vCard converters SHOULD use the title of the page where the hCard is found (e.g. the <title> element in HTML documents) to construct the NAME property, MAY output a PROFILE value of "VCARD" per RFC2426, SHOULD use the URL of the page where the hCard is found to construct the SOURCE property (e.g. perhaps as a parameter to a URL/service that converts hCards to vCards), for an output vCard stream (e.g. a .vcf file). Only services/applications that output actual vCards should write the PRODID property, with the product identifier for said service/application. Similarly, only such services/applications should write the VERSION property, with the value "3.0" (without quotes) per RFC2426 Section 3.6.9.

Organization Contact Info

If the "FN" and "ORG" (organization) properties have the exact same value (typically because they are set on the same element, e.g. class="fn org"), then the hCard represents contact information for a company, organization or place and SHOULD be treated as such. In this case the author also MUST NOT set the "N" property, or set it (and any sub-properties) explicitly to the empty string "". Thus parsers SHOULD handle the missing "N" property, in this case by implying empty values for all the "N" sub-properties.

Implied "N" Optimization

Although vCard requires that the "N" property be present, the authors of the vCard specification (RFC2426) themselves do not include "N" properties in their vCards near the end of the spec (p.38). This apparent contradiction can be resolved by simply allowing the "FN" property to imply "N" property values in typical cases provided in the spec. We do so explicitly in hCard.

If "FN" and "ORG" are not the same (see previous section), and the value of the "FN" property is exactly two words (separated by whitespace), and there is no explicit "N" property, then the "N" property is inferred from the "FN" property. For "FN"s with either one word see below, and for three or more, the author MUST explicitly markup the "N", except for the organization contact info case, see above for that.

The content of "FN" is broken into two "words" separated by whitespace.

The first word of the "FN" is interpreted as the "given-name" for the "N" property.

The second/last word of the "FN" is interpreted as the "family-name" for the "N" property.

Exception: If the first word ends in a "," comma, then the first word (minus the comma at the end) is interpreted as the "family-name" and the second word is interpreted as the "given-name".

This allows simplification in the typical case of people stating:

given-name (space) family-name

family-name (comma) given-name

Implied "nickname" Optimization

Due to the prevalence of the use of nicknames/handles/usernames in actual content published on the Web (e.g. authors of reviews), hCard also has an implied "nickname" optimization to handle this.

Similar to the implied "n" optimization, if "FN" and "ORG" are not the same, and the value of the "FN" property is exactly one word, and there is no explicit "N" property, then:

The content of the "FN" MUST be treated as a "nickname" property value.

Parsers SHOULD handle the missing "N" property by implying empty values for all the "N" sub-properties.

Though parsers MUST follow the implied nickname optimization, publishers SHOULD explicitly indicate the "nickname" even in this case, e.g.:

<spanclass="vcard"><spanclass="fn nickname">daveman692</span></span>

The hCard MAY have additional explicit "nickname" property values in addition to the implied nickname.

Implied "organization-name" Optimization

The "ORG" property has two subproperties, organization-name and organization-unit. Very often authors only publish the organization-name. Thus if an "ORG" property has no "organization-name" inside it, then its entire contents MUST be treated as the "organization-name".

Tags as Categories

Categories in hCard MAY be represented by tags with rel-tag. When a category property is a rel-tag, the tag (as defined by rel-tag) is used for that category.

type subproperty values

The 'type' subproperty in particular takes different values depending on which property it is a subproperty of. These 'type' subproperty values are case-INSENSITIVE, meaning "Home" is the same as "home", as well as multivalued, e.g. a tel can be home and preferred:

adr tel email types

The following lists are informative. See RFC2426 sections 3.2.1 ADR, 3.3.1 TEL, and 3.3.2 EMAIL respectively for normative type values. They are repeated here for convenience. Default type subproperty value(s) is(are) first in each list and indicated in ALL CAPS. types may be multivalued.

Note: The version information is unnecessary in hCard markup directly since the version will be defined by the profile of hCard that is used/referred to in the 'profile' attribute of the <head> element.

Live example

Here is Commercenet's contact details, as a live hCard which will be detected, on this page, by microformat parsing tools:

CommerceNet

http://www.commerce.net/

Work:

169 University Avenue

Palo Alto, CA94301

USA

Work +1-650-289-4040

Fax +1-650-289-4041

Email info@commerce.net

The mark-up, emboldening omitted for clarity, with the following semantic improvements:

Buttons

Copyright

Per the public domain release on the authors' user pages (Tantek Çelik, Brian Suda) this specification is released into the public domain.

Public Domain Contribution Requirement. Since the author(s) released this work into the public domain, in order to maintain this work's public domain status, all contributors to this page agree to release their contributions to this page to the public domain as well. Contributors may indicate their agreement by adding the public domain release template to their user page per the Voluntary Public Domain Declarations instructions. Unreleased contributions may be reverted/removed.

Specifications That Use hCard

Similar Work

Inspiration and Acknowledgments

This section is informative.
Thanks to: my good friend Vadim who introduced me to vCard many years ago, and if I'd only paid more attention then, perhaps I could have helped a lot of people avoid wasting a lot of time reinventing various standards wheels.

Plural Properties Singularized

Since plural property names become their singular equivalents, even if the original plural property permitted only a single value with multiple components, those multiple components are represented each with their own singularly named property and the the property is effectively multivalued and subject to the above treatment of multivalued properties.