[uf-discuss] hCard, i18n and screen readers

Toby Inkster mail at tobyinkster.co.uk
Sun Jan 16 10:40:48 PST 2011


On Tue, 11 Jan 2011 17:06:33 -0800
Jeff <codedread at gmail.com> wrote:

> Doesn't HTML5 microdata use the <meta> element for this purpose?

That doesn't really work outside XHTML.

The problem is that the HTML5 parsing algorithm hoists <meta> elements
into the document head. In other words:

  <!doctype html>
  <head><title>Example</title></head>
  <body>
    <meta name="foo" content="bar">
    <script>
      var heads = document.getElementsByTagName('head');
      var metas = heads[0].getElementsByTagName('meta');
      window.alert(metas[0].name + metas[0].content);
    </script>
  </body>

Will alert "foobar". The browser assumes that you really meant to put
the <meta> element in the head. This behaviour is inherited from legacy
browsers who made this assumption because <meta> has never been allowed
in the <body>.

RDFa's content attribute is a nice solution for hiding a machine
readable value, and somewhat less of a hack:

e.g.

  <p about="#i" rel="foaf:based_near">
    I live in <span property="geo:lat_long"
    content="50.875627;0.017855">Lewes (50°52′N, 0°1′E)</span>
  </p>

-- 
Toby A Inkster
<mailto:mail at tobyinkster.co.uk>
<http://tobyinkster.co.uk>




More information about the microformats-discuss mailing list