hcard: Difference between revisions
AndyMabbett (talk | contribs) (rv moving to "hcard implementations") |
(explicitly release my contributions to hcard into the public domain.) |
||
Line 279: | Line 279: | ||
== Copyright == | == Copyright == | ||
{{MicroFormatCopyrightStatement2004}} | {{MicroFormatCopyrightStatement2004}} | ||
* [[User:Tantek|Tantek]]: I release all my contributions to this specification into the public domain and I encourage the other authors to do so as well. | |||
== Patents == | == Patents == |
Revision as of 18:16, 18 July 2007
hCard
hCard is a simple, open, distributed format for representing people, companies, organizations, and places, using a 1:1 representation of vCard (RFC 2426) properties and values in semantic XHTML. hCard is one of several open microformat standards suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.
Want to get started with writing an hCard? Use the hCard creator to write up some contact information and publish it, or follow the hCard authoring tips to add hCard markup to your current contact page.
Specification
- Editor
- Tantek Çelik, Technorati, Inc.
- Authors
- Tantek Çelik, Technorati, Inc, Brian Suda
- Acknowledgments
- See acknowledgments.
Microformats copyright and patents statements apply.
Introduction
The vCard standard (RFC 2426), has been broadly interoperably implemented (e.g. Apple's "Address Book" application built into MacOSX).
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 XHTML. 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.
Format
In General
The vCard standard (RFC 2426) forms the basis of hCard.
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 XHTML 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 List
hCard properties (sub-properties in parentheses like this)
Required:
- fn
- n* (family-name, given-name, additional-name, honorific-prefix, honorific-suffix)
Optional:
- nickname, sort-string
- url, email (type, value), tel** (type, value)
- adr (post-office-box, extended-address, street-address, locality, region, postal-code, country-name, type, value), label
- geo (latitude, longitude), tz
- photo, logo, sound, bday
- title, role, org (organization-name, organization-unit)
- category, note
- class, key, mailer, uid, rev
Property Notes
* The 'n' property is optional if any implied 'n' optimization rules are in effect.
** tel - Authors MAY want to follow the E.123 standard for writing values of telephone numbers.
Singular vs. Plural Properties
Singular properties: 'fn', 'n', 'bday', 'tz', 'geo', 'sort-string', 'uid', 'class'. For properties which are singular, the first descendant element with that class should take effect, any others being ignored.
All other properties can 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 should be 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 introduced 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:
vCard:
TEL;TYPE=HOME:+1.415.555.1212
hCard:
<span class="tel"> <span class="type">home</span>: <span class="value">+1.415.555.1212</span> </span>
This hCard fragment could be displayed as:
home: +1.415.555.1212
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 RFC 2426. 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 (X)HTML documents) to construct the NAME property, MAY output a PROFILE value of "VCARD
" per RFC 2426, 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 RFC 2426 Section 3.6.9.
Organization Contact Info
If the "FN" and "ORG" 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 MUST also 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 (RFC 2426) 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 OR if the second word is a single character (optionally followed by a period "."), then the first word (minus the comma at the end if any) 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
- family-name (comma) given-name-first-initial
- family-name (space) given-name-first-initial (optional period)
Implied "nickname" Optimization
Due to the prevalence of the use of nicknames/handles/usernames on the Web 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" is treated as a "nickname" property value.
- Parsers should handle the missing "N" property by implying empty values for all the "N" sub-properties.
Note: 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 can optionally 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:
vCard:
TEL;TYPE=HOME,PREF:+1.415.555.1212
hCard:
<span class="tel"><span class="type">Home</span> (<span class="type">pref</span>erred): <span class="value">+1.415.555.1212</span> </span>
This could be displayed as:
Home (preferred): +1.415.555.1212
The following lists are informative. See RFC 2426 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.
- adr type: INTL, POSTAL, PARCEL, WORK, dom, home, pref
- tel type: VOICE, home, msg, work, pref, fax, cell, video, pager, bbs, modem, car, isdn, pcs
- email type: INTERNET, x400, pref, "other IANA registered address types"
XMDP Profile
See hcard-profile for the XMDP profile of hCard which contains the above complete list of properties, with references to their RFC 2426 definitions.
Parsing Details
See hCard parsing.
Examples
This section is informative.
Sample vCard
Here is a sample vCard:
BEGIN:VCARD VERSION:3.0 N:Çelik;Tantek FN:Tantek Çelik URL:http://tantek.com/ ORG:Technorati END:VCARD
and an equivalent in hCard with various elements optimized appropriately. See hCard Example 1 for the derivation.
<div class="vcard"> <a class="url fn" href="http://tantek.com/">Tantek Çelik</a> <div class="org">Technorati</div> </div>
This hCard might be displayed as:
Tantek Çelik
Technorati
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 are the WikiMedia Foundation's contact details, as a live hCard which will be detected, on this page, by microformat parsing tools:
The mark-up (wrapped, and emboldening omitted, for clarity) used is:
<div class="vcard"> <div class="fn org">Wikimedia Foundation Inc.</div> <div class="adr"> <div class="street-address">200 2nd Ave. South #358</div> <div> <span class="locality">St. Petersburg</span>, <abbr class="region" title="Florida">FL</abbr> <span class="postal-code">33701-4313</span> </div> <div class="country-name">USA</div> </div> <div>Phone: <span class="tel">+1-727-231-0101</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-727-258-0207</span></span> </div> </div>
More Examples
See hCard examples for more examples, including all examples from vCard RFC 2426 converted into hCard.
Buttons
You can use these buttons on pages with hCards. See buttons#hCard for any recent additions.
- (mirror: )
- CSS-powered button, as evidenced at microformat badges @ re-run
Examples in the wild
This section is informative. The number of hCard examples in the wild has expanded far beyond the capacity of being kept inline in this specification. They have been moved to a separate page.
See hCard Examples in the wild.
Implementations
This section is informative. The number of hCard implementations has also expanded beyond the capacity of keeping them inline. They have been moved to a separate page.
Copyright
This specification is (C) 2004-2024 by the authors. However, the authors intend to submit (or already have submitted, see details in the spec) this specification to a standards body with a liberal copyright/licensing policy such as the GMPG, IETF, and/or W3C. Anyone wishing to contribute should read their copyright principles, policies and licenses (e.g. the GMPG Principles) and agree to them, including licensing of all contributions under all required licenses (e.g. CC-by 1.0 and later), before contributing.
- Tantek: I release all my contributions to this specification into the public domain and I encourage the other authors to do so as well.
Patents
This specification is subject to a royalty free patent policy, e.g. per the W3C Patent Policy, and IETF RFC3667 & RFC3668.
References
Normative References
- XHTML 1.0 SE
- vCard RFC2426
- ITU recommendation E.123 format of telephone numbers (chargeable document)
Informative References
- hCard history
- X.520 in Postscript (HTMLization courtesy of Google Cache) - vCard refers to ROLE as being "based on the X.520 Business Category explanatory attribute".
- HTML reformatted version of RFC2426
- CSS1
- XHTML 1.1
- Wikipedia summary of ITU-T Recommendation E.123 - for "TEL" values.
- Internet Mail Consortium Personal Data Interchange vCard and vCalendar
Specifications That Use hCard
Similar Work
Inspiration and Acknowledgments
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.
Notes on derivation from vCard
This section is informative.
Semantic XHTML Design Principles
Note: the Semantic XHTML Design Principles were written primarily within the context of developing hCard and hCalendar, thus it may be easier to understand these principles in the context of the hCard design methodology (i.e. read that first). Tantek
XHTML is built on XML, and thus XHTML based formats can be used not only for convenient display presentation, but also for general purpose data exchange. In many ways, XHTML based formats exemplify the best of both HTML and XML worlds. However, when building XHTML based formats, it helps to have a guiding set of principles.
- Reuse the schema (names, objects, properties, values, types, hierarchies, constraints) as much as possible from pre-existing, established, well-supported standards by reference. Avoid restating constraints expressed in the source standard. Informative mentions are ok.
- For types with multiple components, use nested elements with class names equivalent to the names of the components.
- Plural components are made singular, and thus multiple nested elements are used to represent multiple text values that are comma-delimited.
- Use the most accurately precise semantic XHTML building block for each object etc.
- Otherwise use a generic structural element (e.g.
<span>
or<div>
), or the appropriate contextual element (e.g. an<li>
inside a<ul>
or<ol>
). - Use class names based on names from the original schema, unless the semantic XHTML building block precisely represents that part of the original schema. If names in the source schema are case-insensitive, then use an all lowercase equivalent. Components names implicit in prose (rather than explicit in the defined schema) should also use lowercase equivalents for ease of use. Spaces in component names become dash '-' characters.
- Finally, if the format of the data according to the original schema is too long and/or not human-friendly, use
<abbr>
instead of a generic structural element, and place the literal data into the 'title' attribute (where abbr expansions go), and the more brief and human readable equivalent into the element itself. Further informative explanation of this use of<abbr>
: Human vs. ISO8601 dates problem solved
More Semantic Equivalents
For some properties there are HTML elements which better match and convey their semantics. The following properties SHOULD be encoded with the following (X)HTML:
URL
in vCard becomes<a class="url" href="...">...</a>
inside the element withclass="vcard"
in hCard.- Similarly,
EMAIL
in vCard becomes<a class="email" href="mailto:...">...</a>
PHOTO
in vCard becomes<img class="photo" src="..." alt="Photo of ..." />
or<object class="photo" data="..." type="...">Photo of ...</object>
UID
in vCard simply becomes another semantic applied to a specific URL (or EMAIL) for an hCard.
Singular and Plural derivations
The lists of singular and plural properties have been derived by analyzing the semantics of the individual properties in vCard RFC2426 and determining logically that they MUST be singular per their semantics. See hcard-singular-properties for explanations.
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.
Further Reading
- Digital Web Magazine: Microformats Primer by Garrett Dimon has a good intro to hCard
- Practical Microformats with hCard by Drew McLellan
- Local Search Engine Optimization using Microformats by Chris Silver Smith
- Andrew D. Hume has written a blog post on usable microformats which discusses hCard
- Jesse Skinner's introduction to hCard
- Shaun Shull's great post on How Microformats Affect SEO, including his hCard as an example.
- 24 Ways: Styling hCards with CSS A 24 Ways article - John Allsopp on styling hCard using CSS
- See also blogs discussing this page and the hCard tag
- RFC 4770 - Extensions for Instant Messaging
Related Pages
- hCard
- hCard cheatsheet - hCard properties
- hCard creator (feedback) - create your own hCard.
- hCard authoring - learn how to add hCard markup to your existing contact info.
- hCard examples - example usage of various classes within hCard.
- hCard examples in the wild - an on-going list of websites which use hCards.
- hcard-supporting-user-profiles - sites with user profiles marked up with hCard - a very common example.
- hCard FAQ - if you have any questions about hCard, check here.
- hCard implementations - websites or tools which either generate or parse hCards.
- hCard parsing - normative details of how to parse hCards.
- hCards and pages - semantic distinctions between different hCards on a page, and how to identify each
- hcard-user-interface - techniques and issues surrounding user-interfaces to author, publish, and display hCards.
- hCard profile - the XMDP profile for hCard
- hCard singular properties - an explanation of the list of singular properties in hCard.
- hCard tests - a wiki page with actual embedded hCards to try parsing.
- hCard advocacy - encourage others to use hCard
- hCard "to do" - jobs to do
The hCard specification is a work in progress. As additional aspects are discussed, understood, and written, they will be added. These thoughts, issues, and questions are kept in separate pages.
- hCard brainstorming - brainstorms and other explorations relating to hCard.
- hcard-parsing-brainstorming - brainstorming specific to parsing of hCard
- geo brainstorming
- hCard feedback - general feedback (as opposed to specific issues).
- hCard issues - specific issues with the specification.
- vCard errata - corrections to the vCard specification, which underlies hCard.
- vCard suggestions - suggested improvements to the vCard specification.