Search code examples
htmlsemantic-markupmicrodata

Is it possible to use a page's meta description as microdata?


i'm wondering if something like the following is fine..

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Microdata Example</title>
    <meta id="site-description" name="description" content="description text here">
</head>
<body itemscope itemref="site-description" itemtype="http://schema.org/Organization">
    <h1 itemprop="name">Foo</h1>
    <img itemprop="image" src="bar.jpg">
</body>
</html>

Solution

  • This won’t work.

    The itemref attribute is used to reference Microdata properties, but your referenced meta element doesn’t have an itemprop attribute.

    And you can’t add an itemprop attribute to the meta element if it has a name attribute.

    If you don’t want to have this description visible on the page, you could

    • add the meta element in the head, using itemref:

      <head>
          <meta name="description" content="description text here">
          <meta id="site-description" itemprop="description" content="description text here">
      </head>
      <body itemscope itemref="site-description" itemtype="http://schema.org/Organization">
      </body>
      
    • add the meta element in the body, not using itemref:

      <head>
          <meta name="description" content="description text here">
      </head>
      <body itemscope itemtype="http://schema.org/Organization">
          <meta itemprop="description" content="description text here">
      </body>
      

    (Assuming that you want to use Schema.org’s description property.)