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 2018-02-22, the editors have made this specification available under the Open Web Foundation Agreement Version 1.0.

else if data.p-x[value] or input.p-x[value], then return the value attribute

else if img.p-x[alt] or area.p-x[alt], then return the alt attribute

else return the textContent of the element, replacing any nested <img> elements with their alt attribute if present, or otherwise their src attribute if present, resolving any relative URLs, and removing all leading/trailing whitespace.

parsing a u- property

To parse an element for a u-x property value whether explicit "u-*" or backcompat equivalent:

if a.u-x[href] or area.u-x[href], then get the href attribute

else if img.u-x[src] or audio.u-x[src] or video.u-x[src] or source.u-x[src], then get the src attribute

if there is a gotten value, return the normalized absolute URL of it, following the containing document's language's rules for resolving relative URLs (e.g. in HTML, use the current URL context as determined by the page, and first <base> element if any).

else if .h-x>img:only-child[alt]:not([alt=""]):not[.h-*] then use that img alt for name

else if .h-x>area:only-child[alt]:not([alt=""]):not[.h-*] then use that area alt for name

else if .h-x>abbr:only-child[title]:not([title=""]) then use that abbr title for name

else if .h-x>:only-child>img:only-child[alt]:not([alt=""]):not[.h-*] then use that img alt for name

else if .h-x>:only-child>area:only-child[alt]:not([alt=""]):not[.h-*] then use that area alt for name

else if .h-x>:only-child>abbr:only-child[title]:not([title=""]) use that abbr title for name

else use the textContent of the .h-x for name

drop all leading and trailing white-space from name

if no explicit "photo" property,

then imply by:

if img.h-x[src] then use src for photo

else if object.h-x[data] then use data for photo

else if .h-x>img[src]:only-of-type:not[.h-*] then use that img src for photo

else if .h-x>object[data]:only-of-type:not[.h-*] then use that object data for photo

else if .h-x>:only-child>img[src]:only-of-type:not[.h-*] then use that img src for photo

else if .h-x>:only-child>object[data]:only-of-type:not[.h-*] then use that object data for photo

if there is a gotten photo value, return the normalized absolute URL of it, following the containing document's language's rules for resolving relative URLs (e.g. in HTML, use the current URL context as determined by the page, and first <base> element if any).

if no explicit "url" property,

then imply by:

if a.h-x[href] or area.h-x[href] then use that [href] for url

else if .h-x>a[href]:only-of-type:not[.h-*] then use that [href] for url

else if .h-x>area[href]:only-of-type:not[.h-*] then use that [href] for url

if there is a gotten url value, return the normalized absolute URL of it, following the containing document's language's rules for resolving relative URLs (e.g. in HTML, use the current URL context as determined by the page, and first <base> element if any).

Note: The same markup for a property should not be causing that property to occur in both a microformat and one embedded inside - such a property should only be showing up on one of them. The parsing algorithm has details to prevent that, such as the :not[.h-*] tests above.

parse a hyperlink element for rel microformats

To parse a hyperlink element (e.g. a or link) for rel microformats: use the following algorithm or an algorithm that produces equivalent results:

if the "rel" attribute of the element is empty then exit

set url to the value of the "href" attribute of the element, normalized to be an absolute URL following the containing document's language's rules for resolving relative URLs (e.g. in HTML, use the current URL context as determined by the page, and first <base> element if any).

treat the "rel" attribute of the element as a space separate set of rel values

for each rel value (rel-value)

if there is no key rel-value in the rels hash then create it with an empty array as its value

if url is not in the array of the key rel-value in the rels hash then add url to the array

end for

if there is no key with name url in the top-level "rel-urls" hash then add a key with name url there, with an empty hash value

add keys to the hash of the key with name url for each of these attributes (if present) and key not already set:

"hreflang": the value of the "hreflang" attribute

"media": the value of the "media" attribute

"title": the value of the "title" attribute

"type": the value of the "type" attribute

"text": the text content of the element if any

if there is no "rels" key in that hash, add it with an empty array value

set the value of that "rels" key to an array of all unique items in the set of rel values unioned with the current array value of the "rels" key

rel parse examples

Here are some examples to show how parsed rels may be reflected into the JSON (empty items key).

note backward compatibility details

The parsing algorithm and details refer to "backcompat root classes" (backcompat roots for short) and "backcompat properties". These conditions and steps in the algorithm document how to parse pre-microformats2 microformats which all defined their own specific root class names and explicit sets of properties.

Some details to be aware of (which are explicitly in the algorithm, this is just an informal summary)

If an element has one or more microformats2 root class name(s) (h-*)

all backcompat root class names are ignored on that element.

all backcompat properties, without an intervening root class name, are ignored inside that element