h-card: Difference between revisions
(Added parsed JSON to primary examples) |
(→Properties: clarified u-uid, u-logo as set apart from u-photo) |
||
Line 105: | Line 105: | ||
* '''<code>p-nickname</code>''' - nickname/alias/handle | * '''<code>p-nickname</code>''' - nickname/alias/handle | ||
* '''<code>u-email</code>''' - email address | * '''<code>u-email</code>''' - email address | ||
* '''<code>u-logo</code>''' | * '''<code>u-logo</code>''' - a logo representing the person or organisation | ||
* '''<code>u-photo</code>''' | * '''<code>u-photo</code>''' | ||
* '''<code>u-url</code>''' - home page | * '''<code>u-url</code>''' - home page | ||
* '''<code>u-uid</code>''' - unique identifier | * '''<code>u-uid</code>''' - unique identifier, often canonical URL | ||
* '''<code>p-category</code>''' - category/tag | * '''<code>p-category</code>''' - category/tag | ||
* '''<code>p-adr</code>''' - postal address, optionally embed an [[h-adr]] {{main|h-adr}} | * '''<code>p-adr</code>''' - postal address, optionally embed an [[h-adr]] {{main|h-adr}} |
Revision as of 22:08, 6 October 2014
<entry-title>h-card</entry-title> Tantek Çelik (Editor)
h-card is a simple, open format for publishing people and organisations on the web. h-card is one of several open microformat draft standards suitable for embedding data in HTML/HTML5.
h-card is the microformats2 update to hCard.
Per CC0, to the extent possible under law, the editors have waived all copyright and related or neighboring rights to this work. In addition, as of 2024-10-31, the editors have made this specification available under the Open Web Foundation Agreement Version 1.0.
Example
Here is a simple minimal person example:
<a class="h-card" href="http://example.com">Joe Bloggs</a>
Parsed JSON:
{
"items": [
{
"type": [
"h-card"
],
"properties": {
"name": [
"Joe Bloggs"
],
"url": [
"http://example.com"
]
}
}
]
}
And a slightly more complete example:
<p class="h-card">
<img class="u-photo" src="http://example.org/photo.png" alt="" />
<a class="p-name u-url" href="http://example.org">Joe Bloggs</a>
<a class="u-email" href="mailto:joebloggs@example.com">joebloggs@example.com</a>,
<span class="p-street-address">17 Austerstræti</span>
<span class="p-locality">Reykjavík</span>
<span class="p-country-name">Iceland</span>
</p>
Parsed JSON:
{
"items": [
{
"type": [
"h-card"
],
"properties": {
"photo": [
"http://example.org/photo.png"
],
"name": [
"Joe Bloggs"
],
"url": [
"http://example.org"
],
"email": [
"mailto:joebloggs@example.com"
],
"street-address": [
"17 Austerstræti"
],
"locality": [
"Reykjavík"
],
"country-name": [
"Iceland"
]
}
}
]
}
Get started
The class h-card
is a root class name that indicates the presence of an h-card.
For minimal examples where at most p-name
, u-url
and u-photo
are required (such as the first given above), only the root class name is needed — see implied properties.
For more complex examples, the root class name must be placed on an element which encloses all the desired properties, and then the properties themselves marked up using the classnames given below.
See microformats2-parsing to learn more about property classnames.
Properties
h-card properties, inside an element with class h-card:
p-name
- The full/formatted name of the person or organisationp-honorific-prefix
- e.g. Mrs., Mr. or Dr.p-given-name
- given (often first) namep-additional-name
- other/middle namep-family-name
- family (often last) namep-sort-string
- string to sort byp-honorific-suffix
- e.g. Ph.D, Esq.p-nickname
- nickname/alias/handleu-email
- email addressu-logo
- a logo representing the person or organisationu-photo
u-url
- home pageu-uid
- unique identifier, often canonical URLp-category
- category/tagp-adr
- postal address, optionally embed an h-adrMain article: h-adrp-post-office-box
p-extended-address
- apartment/suite/room name/number if anyp-street-address
- street number + namep-locality
- city/town/villagep-region
- state/county/provincep-postal-code
- postal code, e.g. US ZIPp-country-name
- country namep-label
p-geo
oru-geo
, optionally embed an h-geoMain article: h-geop-latitude
- decimal latitudep-longitude
- decimal longitudep-altitude
- decimal altitudep-tel
- telephone numberp-note
- additional notesdt-bday
- birth dateu-key
- cryptographic public key e.g. SSH or GPGp-org
- affiliated organization, optionally embed an h-cardp-job-title
- job title, previously 'title' in hCard, disambiguated.p-role
- description of roleu-impp
per RFC 4770, new in vCard4 (RFC6350)p-sex
- biological sex, new in vCard4 (RFC6350)p-gender-identity
- gender identity, new in vCard4 (RFC6350)dt-anniversary
All properties are optional.
Status
h-card is a microformats.org draft specification. Public discussion on h-card takes place on h-card-feedback, the #microformats irc channel on irc.freenode.net, and microformats-new mailing list.
h-card is ready to use and implemented in the wild, but for backwards compatibility you should also mark h-cards up as classic hCards.
Property Details
(stub, to be expanded)
p-adr
p-adr
can optionally embed an h-adr to cluster associated structured address properties. E.g. adding "p-adr" to the example earlier:
<div class="h-card">
<p class="p-name">Joe Bloggs</p>
<p class="p-adr h-adr">
<span class="p-street-address">17 Austerstræti</span>
<span class="p-locality">Reykjavík</span>
<span class="p-country-name">Iceland</span>
</p>
</div>
Q: Why would you use "p-adr" to cluster associated structured address properties?
A: Because if you have more than one structured address, it helps to cluster which properties go with which address, e.g. home vs. work.
p-tel
Note: use of 'value' within 'p-tel' should be automatically handled by the support of the value-class-pattern. And for now, the former hCard 'type' subproperty of 'tel' is dropped/ignored. If there is demonstrable documented need for additional tel types (e.g. fax), we can introduce new flat properties as needed (e.g. p-tel-fax).
Reserved properties
Reserved properties (not used much, if at all, in practice):
p-organization-name
p-organization-unit
p-tz
- timezone offset, e.g.<data class="p-tz" value="-0800">PST</data>
dt-rev
Examples in the wild
Real world in the wild examples:
- ... add uses of h-card you see in the wild here.
- App.net rolled out support for h-card and h-entry on all profile pages and permalink pages as of 2013-08-06 (example)
- Brett Comnes marks up his posts with h-card (example)
- Ben Werdmuller marks up his homepage and posts with h-card example)
- Sandeep Shetty marks his homepage and posts up with h-card and h-entry ([sandeep.io/101 example])
- spreadly marks up share permalink pages with minimal h-cards inside h-entry (example)
- Laurent Eschenauer marks his homepage profile up using h-card
- Tom Morris marks himself up with h-card as well as venues he’s checked into (example)
- W3Conf 2013 uses h-card for all the event speakers and notable attendees. The h-cards make particularly good use of implied name, url, and photo properties.
- SemPress is a WordPress theme that supports h-card, h-feed/h-entry and h-as-*
- The Pastry Box Project use h-card markup on their homepage and individual thoughts pages
- Tom Morris uses h-card and XFN to markup his blogroll.
- Aaron Parecki uses h-card to markup both authorship and references to people in his notes permalinks, e.g. 2012/230/reply/1.
- Tantek Çelik uses h-card on his home page as well as within h-entrys on permalink pages to indicate authorship.
- Barnaby Walters uses h-card on his home page, as well as within h-entries for notes and articles, both to indicate authorship and also when mentioning people within the body of the notes.
- microformats.org at 7 years presentation with and h-card markup for people and organizations.
- Rise of the Indie Web hCards (from Personal Democracy Forum 2012 #pdf12 #pdf2012) has microformats2 h-card markup
- WebMaker by Mozilla has microformats2 h-card on event search (e.g. search near Portland Oregon) and event pages (e.g. IndieWebCamp 2012).[1]
- WebFWD by Mozilla has microformats2 h-card markup on experts and team pages
- IndieWebCamp has microformats2 h-event markup with embedded h-cards for the organizers and the location.
- Mozilla Events page has microformats2 h-event markup with attendees marked up with h-card.
Validating
- indiewebify.me h-card validator parses h-card markup and makes suggestions for things to add, with code samples
Test and validate microformats2 markup in general with:
- https://pin13.net/mf2/ - enter your markup directly
- https://pin13.net/ - enter a URL to a page to test where it says "Microformats Parser"
Backward Compatibility
Publisher Compatibility
For backward compatibility, you may wish to use classic hCard classnames in addition to the more future-proof h-card properties, for example:
<p class="h-card vcard">
<span class="p-name fn">Joe Bloggs</span>,
<span class="p-org org">Awesome Nonprofit</span>
...
</p>
The class vcard
is a backward compatible root class name that indicates the presence of an hCard.
fn, org, and all the other backward compatibility hCard property class names are listed below.
Parser Compatibility
Microformats parsers SHOULD detect classic properties only if a classic root class name is found and parse them as microformats2 properties.
If an "h-card" is found, don't look for a "vcard" on the same element.
Compat. root class name: vcard
Properties: (parsed as p- plain text unless otherwise specified)
fn
- parse asp-name
honorific-prefix
given-name
additional-name
family-name
honorific-suffix
nickname
email
- parse as u-logo
- parse as u-photo
- parse as u-url
- parse as u-uid
- parse as u-category
adr
- parse asp-adr h-adr
including compat root classadr
extended-address
street-address
locality
region
postal-code
country-name
label
geo
- parse asp-geo h-geo
including compat root classgeo
latitude
longitude
tel
note
bday
- parse as dt-key
- parse as u-org
organization-name
organization-unit
title
- parse as p-job-titlerole
Reserved: (backward compat properties that parsers MAY implement, if they do, they MUST implement in this way:
tz
rev
- parse as dt-
Background
This work is based on the existing hCard and vcard specifications.
Design Principles
(stub, expand)