html5: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
(note that problems with microdata and forked nature have not been resolved, provide concrete recommendations and reasons for, note Google Rich Snippets alternate vocab forks)
m (s/<source>/<syntaxhighlight>/)
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<entry-title>Microformats in HTML5</entry-title>
{{DISPLAYTITLE:Microformats in HTML5}}


''This page is to document '''future''' use of microformats in [http://www.w3.org/html/wg/html5 HTML5]. None of the items documented are supported now, and may change upon proper development within the microformats community, or changes in the HTML 5 specification. This page is to track HTML5 enabled enhancements to microformats, and issues that HTML5 raises. It may be used to track issues which we need to push back into the HTML 5 development process.''
''This page is to document '''future''' use of microformats in [http://www.w3.org/html/wg/html5 HTML5]. None of the items documented are supported now, and may change upon proper development within the microformats community, or changes in the HTML 5 specification. This page is to track HTML5 enabled enhancements to microformats, and issues that HTML5 raises. It may be used to track issues which we need to push back into the HTML 5 development process.''
Line 9: Line 9:
=== time element ===
=== time element ===
'''<code>time</code> element for representing date times'''. In HTML5, the machine form of datetimes can be represented natively. In some cases it may be possible to replace the date-time design pattern with native HTML5.
'''<code>time</code> element for representing date times'''. In HTML5, the machine form of datetimes can be represented natively. In some cases it may be possible to replace the date-time design pattern with native HTML5.
* <code>time</code> takes an optional <code>pubdate</code> attribute, to indicate the publication date of an <code>article</code>. Synonymous with [[hAtom]] <code>published</code>, may imply [[hAtom]] <code>updated</code>, may imply [[hReview]] <code>dtreviewed</code>, may imply [[hListing]] <code>dtlisted</code>
Note that there are documented [http://wiki.whatwg.org/wiki/Time limitations in the time element].  Please add additional opinions and use cases to that wiki page so that we can help improve the time element.


* Recommendation: Use the [[value-class-pattern]], in particular preferably <strong>date-time-separation</strong> for accessibly marking up dates and times while following the <abbr title="Don't Repeat Yourself">DRY</abbr> [[principle]] as much as possible.
* Recommendation: Use the [[value-class-pattern]], in particular preferably <strong>date-time-separation</strong> for accessibly marking up dates and times while following the <abbr title="Don't Repeat Yourself">DRY</abbr> [[principle]] as much as possible.


=== article element ===
* [[parsers#HTML::Microformats|HTML::Microformats]] and its predecessors have supported the <code>time</code> element since July 2008.
'''<code>article</code>''' element for major, independent compositions of content within a page. Perhaps synonymous with [[hAtom]] <code>hentry</code>. Could be parsed as <code>hentry</code> within explicit <code>hfeed</code> blocks?


=== data attributes ===
* Try http://dev.h2vx.com/ (the beta version of [[H2VX]]) as it now has preliminary support for <code>&lt;time datetime&gt;</code> as well as the new semantic HTML5 elements.
'''<code>data-</code> naming convention for tag attributes'''. the draft specification states that any attribute that starts with "data-" will be treated as a storage area for private data.
* Note that the data-* stuff is explicitly <em>not</em> for microformats. Those attributes are defined in such a way that browsers will never do anything special with them, ever. They are intended for script authors to have a space in which they can play without ever clashing with anything the browser does. There may be some cases of private [[poshformats]] that are never intended for interchange that may be used in data-* attributes.


== Additions beyond HTML5 ==
Note: that there are documented [http://wiki.whatwg.org/wiki/Time proposals to extend the time element]. Please add additional opinions and use cases to that wiki page so that we can help improve the time element.
=== microdata ===
'''[[microdata]]''' is an extension to HTML5 that provides a set of attributes and associated DOM APIs for semantically marking up and extracting data from existing content in web pages, similar to microformats but with new attributes.
* <code>itemprop</code> attribute is a more specific version of <code>class</code>, for field names
* <del><code>subject</code> attribute allows semantically linking within the page. Conceptually similar to the [[include-pattern]].</del>
* <code>itemref</code> attribute allows including properties elsewhere on the page that are not descendants of <code>itemscope</code>. Takes space-separated ids (for example <code>itemref="address phone"</code> would include the elements with <code>id="address"</code> and <code>id="phone"</code>). Conceptually similar to the [[include-pattern]].
* <code>content</code> attribute on the <code>meta</code> element can be used to include invisible data that is not part of the content. As current browsers move <code>meta</code> inside <code>&lt;head&gt;</code>, make sure to include via <code>itemref</code>. Conceptually similar to the 'value-title' feature of the [[value-class-pattern]].
* <code>itemscope</code> attribute identifies blocks to be marked as structured data. Conceptually similar to the [[mfo]] brainstorming.
* <code>itemtype</code> attribute to specify the type for an item (for example: <code><nowiki>itemtype="http://microformats.org/profile/hcard"</nowiki></code>)


=== microdata vocabularies ===
There was briefly an optional <code>pubdate</code> attribute, to indicate the publication date of an <code>article</code>, but it was dropped in 2012 since it is both unnecessary and insufficient. Rather than use the one-off pubdate attribute, it's much better to:
==== microdata vCard vocabulary ====
* Use the [[hAtom]] microformat for articles, and the hAtom <code>published</code> property, as well as the hAtom <code>updated</code> property.
Formerly documented as a separate specification at <nowiki>http://dev.w3.org/html5/mdvcard/</nowiki>, the microdata vCard vocabulary is currently available as [http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#vcard part of WHATWG additions to HTML5].


* Recommendation: use [[hCard]] directly instead, taking into account:
==== hCalendar with time element ====
** the [[hcard-faq|hCard FAQ]] and
Here is the [[hcalendar#Examples|hCalendar spec example]] updated to use section instead of div, and time instead of abbr.
** [[hcard-issues-resolved|resolved]]+[[hcard-issues-closed|closed issues]].  


hCard 1.0.1 (under development) is incorporating these errata.  
<syntaxhighlight lang="html">
<section class="vevent">
<a class="url" href="http://conferences.oreillynet.com/pub/w/40/program.html">
  http://conferences.oreillynet.com/pub/w/40/program.html
</a>
<span class="summary">Web 2.0 Conference</span>:
<time class="dtstart" datetime="2005-10-05">October 5</time>-
<time class="dtend" datetime="2005-10-07">7</time>,
at the <span class="location">Argent Hotel, San Francisco, CA</span>
</section>
</syntaxhighlight>


Using hCard will produce Google Rich Snippets, as well as work with [[yahoo-search]], and [[Firefox]] [[Operator]] and other tools.
=== article element ===
'''<code>article</code>''' element for major, independent compositions of content within a page. Perhaps synonymous with [[hAtom]] <code>hentry</code>. Could be parsed as <code>hentry</code> within explicit <code>hfeed</code> blocks?


Note:
=== data attributes ===
* Avoid the "microdata vCard vocabulary" as in many ways it is an out-of-date fork/snapshot of hCard, even though portions of it appear to based directly on the vCard RFC. as well.
'''<code>data-</code> naming convention for tag attributes'''. the draft specification states that any attribute that starts with "data-" will be treated as a storage area for private data.
* Avoid Google’s Rich Snippets vocabularies ([http://www.data-vocabulary.org/Person/ Person] and [http://www.data-vocabulary.org/Organization/ Organization]), which are also forks of hCard/vCard, and are only implemented by Google currently.
* Note that the data-* stuff is explicitly <em>not</em> for microformats. Those attributes are defined in such a way that browsers will never do anything special with them, ever. They are intended for script authors to have a space in which they can play without ever clashing with anything the browser does. There may be some cases of private [[poshformats]] that are never intended for interchange that may be used in data-* attributes.


==== microdata vEvent vocabulary ====
Since data-* attributes are not for general data interchange or generic APIs supported by multiple sites / pieces of software, what are actual valid uses of data-* attributes? One example (feel free to add more)
Formerly documented as a separate specification at <nowiki>http://dev.w3.org/html5/mdvevent/</nowiki>, the microdata vEvent vocabulary is currently available as [http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#vevent part of WHATWG additions to HTML5].
* Twitter's use of data-* attributes in markup to be picked up only by Twitter's javascript [https://dev.twitter.com/docs/tweet-button library for Tweet buttons], e.g. <code>data-related="indiewebcamp"</code> - indicates [https://twitter.com/indiewebcamp @indiewebcamp] is a related Twitter account for a tweet button.


* Recommendation: use [[hCalendar]] directly instead, taking into account:
=== new semantic elements ===
** the [[hcalendar-faq|hCalendar FAQ]] and
HTML5 has numerous new semantic elements.
** [[hcalendar-issues-resolved|resolved]]+[[hcalendar-issues-closed|closed issues]].  


hCalendar 1.0.1 (under development) is incorporating these errata. 
Most microformats [[parsers]] probably won't recognize those elements and may ignore them - so avoid using microformats classes on new HTML5 semantic elements for anything in production.


Using hCalendar will produce Google Rich Snippets, as well as work with [[yahoo-search]], and [[Firefox]] [[Operator]] and other tools.
HOWEVER, do try experimenting with microformats and new semantic HTML5,  


Note:
AND try http://dev.h2vx.com/ (the beta version of [[H2VX]]) as it now has preliminary support for the new semantic HTML5 elements as well as <code>&lt;time datetime&gt;</code>.
* Avoid the "microdata vEvent vocabulary" as in many ways it is an out-of-date fork/snapshot of hCalendar's vevent root class name and applicable properties, though portions of it even though portions of it appear to based directly on the iCalendar RFC.
* Avoid Google’s Rich Snippets vocabulary ([http://www.data-vocabulary.org/Event/ Event]), which is also a fork of hCalendar/iCalendar, and are only implemented by Google currently.


==== microdata Licensing Works vocabulary ====
== Changes in HTML5 ==
Formerly documented as a separate specification at <nowiki>http://dev.w3.org/html5/mdwork/</nowiki>, the microdata Licensing Works vocabulary is currently available as [http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#licensing-works part of WHATWG additions to HTML5].
=== The rel/rev attributes ===
 
The <code>rev</code> attribute has been removed from HTML5. The <code>rel</code> attribute can be still be used in the same way, but microformats that assumed the existence of <code>rev</code> and thus only defined a single forward-facing relation may need to be changed to include an opposite relation as well. That is, for every relation that goes in one direction (e.g. [[rel-parent]] of [[xfn]]), you must explicitly name and define the inverse relationship (e.g. [[rel-child]] of [[xfn]]) if the inverse relation is indeed useful.
The [[licensing]] microformat work provides a potential microformat alternative to the microdata Licensing Works vocabulary.
 
Please see: [[licensing-brainstorming]] and provide feedback.


== Additions beyond HTML5 ==
=== microdata ===
{{main|microdata}}
'''[[microdata]]''' is an extension to HTML5 that provides a set of attributes and associated DOM APIs for semantically marking up and extracting data from existing content in web pages, similar to microformats but with new attributes.


== Current microformat compatibility ==
== Current microformat compatibility ==
Line 85: Line 78:
==Issues==
==Issues==
<div class='discussion issues'>
<div class='discussion issues'>
* '''The <code>rev</code> attribute has been removed'''. In HTML5, <code>rel</code> and <code>rev</code> are no-longer paired, and the <code>rel</code> attribute nolonger describes the direction of a relationship. Microformats which use <code>rev</code> will need to use <code>rel</code> instead.
** Or something like data-rev="vote-for"
*** As above, <code>data-</code> attributes are for application-context functionality, ''not'' shared vocabularies. Further, the HTML5 specification makes <code>rel</code> the correct attribute to use, regardless of direction, through the changed specification. --[[User:BenWard|BenWard]] 17:53, 12 May 2009 (UTC)
* '''The <code>profile</code> attribute has been removed'''. In HTML, the <code>profile</code> attribute from the <code>head</code> has been removed, with no direct replacement. This causes issues for GRDDL support. It's been suggested that profile URLs be represented in <code>link</code> elements instead, or even as a custom HTTP header. See [[grddl]] and [[profile-uris]]
* '''The <code>profile</code> attribute has been removed'''. In HTML, the <code>profile</code> attribute from the <code>head</code> has been removed, with no direct replacement. This causes issues for GRDDL support. It's been suggested that profile URLs be represented in <code>link</code> elements instead, or even as a custom HTTP header. See [[grddl]] and [[profile-uris]]
** See [[rel-profile]] which is the replacement for the profile attribute. [[User:Tantek|Tantek]] 23:24, 5 November 2009 (UTC)
** See [[rel-profile]] which is the replacement for the profile attribute. [[User:Tantek|Tantek]] 23:24, 5 November 2009 (UTC)
Line 93: Line 83:
** This is because microdata is designed to be generically parsable, even when the parser does not understand the vocabulary. As such, property names have to be on an explicit attribute, not shared with other, non-data classnames. --[[User:BenWard|BenWard]] 21:12, 4 September 2009 (UTC)
** This is because microdata is designed to be generically parsable, even when the parser does not understand the vocabulary. As such, property names have to be on an explicit attribute, not shared with other, non-data classnames. --[[User:BenWard|BenWard]] 21:12, 4 September 2009 (UTC)
* '''The [http://microformats.org/wiki/value-class-pattern#Date_and_time_parsing recommended removal of the colon in timezone] doesn’t validate''' The relevant uF wiki text is “However the colons ":" separating the hours and minutes of any timezone offset are optional and discouraged in order to make it less likely that a timezone offset will be confused for a time.” ref: [http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#global-dates-and-times HTML5 time microsyntax for &lt;time&gt;] --[[User:Oli|Oli]] 14:40, 14 February 2010 (+9)
* '''The [http://microformats.org/wiki/value-class-pattern#Date_and_time_parsing recommended removal of the colon in timezone] doesn’t validate''' The relevant uF wiki text is “However the colons ":" separating the hours and minutes of any timezone offset are optional and discouraged in order to make it less likely that a timezone offset will be confused for a time.” ref: [http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#global-dates-and-times HTML5 time microsyntax for &lt;time&gt;] --[[User:Oli|Oli]] 14:40, 14 February 2010 (+9)
* '''Some websites are not ready to upgrade to HTML5''' and must stick with HTML4 (or XHTML1 served/interpreted as HTML4) for now. For example:
**  http://www.ascentsir.com/eng - according to [[IRC]] "ChiefRA" on 2011-06-30
</div>
</div>


== see also ==
== see also ==
* [[HTML3]]
* [[HTML3]]

Latest revision as of 21:27, 26 July 2023


This page is to document future use of microformats in HTML5. None of the items documented are supported now, and may change upon proper development within the microformats community, or changes in the HTML 5 specification. This page is to track HTML5 enabled enhancements to microformats, and issues that HTML5 raises. It may be used to track issues which we need to push back into the HTML 5 development process.

If there are things that microformats would like to mark up that aren't handled by HTML5 explicitly, please let the WHATWG know, so we can improve HTML5. This is how the time element came to be, for instance.

New features in HTML5

time element

time element for representing date times. In HTML5, the machine form of datetimes can be represented natively. In some cases it may be possible to replace the date-time design pattern with native HTML5.

  • Recommendation: Use the value-class-pattern, in particular preferably date-time-separation for accessibly marking up dates and times while following the DRY principle as much as possible.
  • Try http://dev.h2vx.com/ (the beta version of H2VX) as it now has preliminary support for <time datetime> as well as the new semantic HTML5 elements.

Note: that there are documented proposals to extend the time element. Please add additional opinions and use cases to that wiki page so that we can help improve the time element.

There was briefly an optional pubdate attribute, to indicate the publication date of an article, but it was dropped in 2012 since it is both unnecessary and insufficient. Rather than use the one-off pubdate attribute, it's much better to:

  • Use the hAtom microformat for articles, and the hAtom published property, as well as the hAtom updated property.

hCalendar with time element

Here is the hCalendar spec example updated to use section instead of div, and time instead of abbr.

<section class="vevent">
 <a class="url" href="http://conferences.oreillynet.com/pub/w/40/program.html">
  http://conferences.oreillynet.com/pub/w/40/program.html
 </a>
 <span class="summary">Web 2.0 Conference</span>: 
 <time class="dtstart" datetime="2005-10-05">October 5</time>-
 <time class="dtend" datetime="2005-10-07">7</time>,
 at the <span class="location">Argent Hotel, San Francisco, CA</span>
</section>

article element

article element for major, independent compositions of content within a page. Perhaps synonymous with hAtom hentry. Could be parsed as hentry within explicit hfeed blocks?

data attributes

data- naming convention for tag attributes. the draft specification states that any attribute that starts with "data-" will be treated as a storage area for private data.

  • Note that the data-* stuff is explicitly not for microformats. Those attributes are defined in such a way that browsers will never do anything special with them, ever. They are intended for script authors to have a space in which they can play without ever clashing with anything the browser does. There may be some cases of private poshformats that are never intended for interchange that may be used in data-* attributes.

Since data-* attributes are not for general data interchange or generic APIs supported by multiple sites / pieces of software, what are actual valid uses of data-* attributes? One example (feel free to add more)

  • Twitter's use of data-* attributes in markup to be picked up only by Twitter's javascript library for Tweet buttons, e.g. data-related="indiewebcamp" - indicates @indiewebcamp is a related Twitter account for a tweet button.

new semantic elements

HTML5 has numerous new semantic elements.

Most microformats parsers probably won't recognize those elements and may ignore them - so avoid using microformats classes on new HTML5 semantic elements for anything in production.

HOWEVER, do try experimenting with microformats and new semantic HTML5,

AND try http://dev.h2vx.com/ (the beta version of H2VX) as it now has preliminary support for the new semantic HTML5 elements as well as <time datetime>.

Changes in HTML5

The rel/rev attributes

The rev attribute has been removed from HTML5. The rel attribute can be still be used in the same way, but microformats that assumed the existence of rev and thus only defined a single forward-facing relation may need to be changed to include an opposite relation as well. That is, for every relation that goes in one direction (e.g. rel-parent of xfn), you must explicitly name and define the inverse relationship (e.g. rel-child of xfn) if the inverse relation is indeed useful.

Additions beyond HTML5

microdata

Main article: microdata

microdata is an extension to HTML5 that provides a set of attributes and associated DOM APIs for semantically marking up and extracting data from existing content in web pages, similar to microformats but with new attributes.

Current microformat compatibility

There seems to be no issue with current implementation of the following microformats in HTML 5:

Requests

Issues

  • The profile attribute has been removed. In HTML, the profile attribute from the head has been removed, with no direct replacement. This causes issues for GRDDL support. It's been suggested that profile URLs be represented in link elements instead, or even as a custom HTTP header. See grddl and profile-uris
    • See rel-profile which is the replacement for the profile attribute. Tantek 23:24, 5 November 2009 (UTC)
  • Microdata itemprop duplicates class data. the new attribute itemprop is designed to hold some meaningful data about an element, but class already exists to hold this data. Unsure of reasons why itemprop required?
    • This is because microdata is designed to be generically parsable, even when the parser does not understand the vocabulary. As such, property names have to be on an explicit attribute, not shared with other, non-data classnames. --BenWard 21:12, 4 September 2009 (UTC)
  • The recommended removal of the colon in timezone doesn’t validate The relevant uF wiki text is “However the colons ":" separating the hours and minutes of any timezone offset are optional and discouraged in order to make it less likely that a timezone offset will be confused for a time.” ref: HTML5 time microsyntax for <time> --Oli 14:40, 14 February 2010 (+9)
  • Some websites are not ready to upgrade to HTML5 and must stick with HTML4 (or XHTML1 served/interpreted as HTML4) for now. For example:

see also