h-card: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
(drop DISPLAYTITLE thing, seems redundant (and confusing for redirects, fragment links etc.))
(editorial: fragments for status and participate, dedup IRC line)
Line 3: Line 3:
h-card is the [[microformats2]] update to [[hCard]].
h-card is the [[microformats2]] update to [[hCard]].


;<span id="Status">Status</span>
;<span id="status">Status</span>
:This is a '''Living Specification''' yet mature enough to encourage additional implementations and [[h-card-issues|feedback]].
:This is a '''Living Specification''' yet mature enough to encourage additional implementations and [https://github.com/microformats/h-card/issues feedback].
;Participate
;<span id="participate">Participate</span>
:[https://github.com/microformats/h-card/issues Open Issues]
:[https://github.com/microformats/h-card/issues Open Issues]
:[[IRC]]: [irc://irc.freenode.net/microformats #microformats on Freenode]
:[[IRC]]
<div class="p-author h-card vcard">
<div class="p-author h-card vcard">
;<span class="p-role role">Editor</span>
;<span class="p-role role">Editor</span>

Revision as of 03:54, 22 June 2021

h-card is a simple, open format for publishing people and organisations on the web. h-card is often used on home pages and individual blog posts. h-card is one of several open microformat draft standards suitable for embedding data in HTML.

h-card is the microformats2 update to hCard.

Status
This is a Living Specification yet mature enough to encourage additional implementations and feedback.
Participate
Open Issues
IRC
Editor
Tantek Çelik
License
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-11-25, the editors have made this specification available under the Open Web Foundation Agreement Version 1.0.

Example

Here are a couple of minimal examples:

<a class="h-card" href="https://tantek.com/">Tantek Çelik</a>, 

<span class="h-card">
  <a class="p-name p-org u-url" href="https://microformats.org/">microformats.org</a>
</span>

Parsed JSON:

{
  "items": [
    {
      "type": ["h-card"],
      "properties": {
        "name": ["Tantek Çelik"],
        "url": ["https://tantek.com/"]
      }
    },
    {
      "type": ["h-card"],
      "properties": {
        "name": ["microformats.org"],
        "org": ["microformats.org"],
        "url": ["https://microformats.org/"]
      }
    }
  ]
}

Note a single element was sufficient for the simple person example with implied name and URL properties, while for an organization, which requires a name and org, it needed explicit markup for the h-card and all properties, though still with only two elements.

Nested h-card example:

<div class="h-card">
  <a class="p-name u-url"
     href="https://blog.lizardwrangler.com/" 
    >Mitchell Baker</a> 
  (<a class="p-org h-card" 
      href="https://mozilla.org/"
     >Mozilla Foundation</a>)
</div>

Parsed JSON:

{
  "items": [{ 
    "type": ["h-card"],
    "properties": {
      "name": ["Mitchell Baker"],
      "url": ["https://blog.lizardwrangler.com/"],
      "org": [{
        "value": "Mozilla Foundation",
        "type": ["h-card"],
        "properties": {
          "name": ["Mozilla Foundation"],
          "url": ["https://mozilla.org/"]
        }
      }]
    }
  }]
}

Note: the nested h-card has implied 'name' and 'url' properties, just like any other root-class-name-only h-card on an <a href> would.

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.

When more than those three minimal properties are needed, 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. All properties are optional and may be plural.

Example h-card with common properties:
  • <div class="h-card">
    • <span class="p-name">Sally Ride</span>
    • <span class="p-honorific-prefix">Dr.</span>
    • <span class="p-given-name">Sally</span>
    • <abbr class="p-additional-name">K.</abbr>
    • <span class="p-family-name">Ride</span>
    • <span class="p-honorific-suffix">Ph.D.</span>,
    • <span class="p-nickname">sallykride</span> (IRC)
    • <div class="p-org">Sally Ride Science</div>
    • <img class="u-photo" src="http://example.com/sk.jpg"/>
    • <a class="u-url" href="http://sally.example.com">w</a>,
    • <a class="u-email" href="mailto:sally@example.com">e</a>
    • <div class="p-tel">+1.818.555.1212</div>
    • <div class="p-street-address">123 Main st.</div>
    • <span class="p-locality">Los Angeles</span>,
    • <abbr class="p-region" title="California">CA</abbr>,
    • <span class="p-postal-code">91316</span>
    • <div class="p-country-name">U.S.A</div>
    • <time class="dt-bday">1951-05-26</time> birthday
    • <div class="p-category">physicist</div>
    • <div class="p-note">First American woman in space.</div>
  • </div>

Core properties:

  • p-name - The full/formatted name of the person or organization
  • p-honorific-prefix - e.g. Mrs., Mr. or Dr.
  • p-given-name - given (often first) name
  • p-additional-name - other (e.g. middle) name
  • p-family-name - family (often last) name
  • p-sort-string - string to sort by
  • p-honorific-suffix - e.g. Ph.D, Esq.
  • p-nickname - nickname/alias/handle
  • u-email - email address
  • u-logo - a logo representing the person or organization (e.g. a face icon)
  • u-photo - a photo of the person or organization
  • u-url - home page or other URL representing the person or organization
  • u-uid - universally unique identifier, preferably canonical URL
  • p-category - category/tag
  • p-adr - postal address, optionally embed an h-adr
    Main article: h-adr
  • p-post-office-box - post office box description if any
  • p-extended-address - apartment/suite/room name/number if any
  • p-street-address - street number + name
  • p-locality - city/town/village
  • p-region - state/county/province
  • p-postal-code - postal code, e.g. US ZIP
  • p-country-name - country name
  • p-label
  • p-geo or u-geo, optionally embed an h-geo
    Main article: h-geo
  • p-latitude - decimal latitude
  • p-longitude - decimal longitude
  • p-altitude - decimal altitude
  • p-tel - telephone number
  • p-note - additional notes
  • dt-bday - birth date
  • u-key - cryptographic public key e.g. SSH or GPG
  • p-org - affiliated organization, optionally embed an h-card
  • p-job-title - job title, previously 'title' in hCard, disambiguated.
  • p-role - description of role
  • u-impp per RFC4770, new in vCard4 (RFC 6350)
  • p-sex - biological sex, new in vCard4 (RFC 6350)
  • p-gender-identity - gender identity, new in vCard4 (RFC 6350)
  • dt-anniversary

Experimental properties currently in use in the wild but not (yet) part of the official h-card spec.

  • u-sound - sound file containing the proper pronunciation of the name property, per vCard (RFC 6350).


Status

h-card is a microformats.org draft specification. Public discussion on h-card takes place on the #microformats channel on irc.freenode.net (view recent discussions), and specific issues may be filed on GitHub.

h-card is ready to use and implemented in the wild. For backwards compatibility you should also mark up top-level h-cards 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, clustering which properties go with which address keeps them deterministically together, instead of depending on array indices or other heuristics.

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).

dt-bday

Using truncated representations of dates for birth date is often good practice as noted in the vcard spec eg

  • 1985-04 for April 1985
  • 1985 for the year 1985
  • --04-12 for April 12th with no specified year

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 of sites and services that publish or consume h-card:

offline

  • spreadly marks up share permalink pages with minimal h-cards inside h-entry

Validating

Main article: validators

Test and validate microformats2 markup in general with:

Implementations

Software implementations that publish or consume h-card, including themes, plugins, or extensions:

(This section is a stub that needs expansion! In practice, nearly every CMS on every indie web site supports publishing h-card by default.)

When adding an implementation, please provide and link to its home page and open source repo if any.

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 as p-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 as p-adr h-adr including compat root class adr
  • extended-address
  • street-address
  • locality
  • region
  • postal-code
  • country-name
  • label
  • geo - parse as p-geo h-geo including compat root class geo
  • latitude
  • longitude
  • tel
  • note
  • bday - parse as dt-
  • key - parse as u-
  • org
  • organization-name
  • organization-unit
  • title - parse as p-job-title
  • role

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)

Additions

We've tried very hard with h-card to stay compatible with the vCard4 vocabulary, and thus additions should be proposed on the vCard4 mailing list.

However, you may still use this wiki to capture additions for h-card here:

See Also