{"id":935,"date":"2011-11-02T16:35:55","date_gmt":"2011-11-02T20:35:55","guid":{"rendered":"http:\/\/www.blizzarddigital.com\/blog\/?p=935"},"modified":"2011-11-14T20:35:01","modified_gmt":"2011-11-15T00:35:01","slug":"html-5-microdata-and-you","status":"publish","type":"post","link":"https:\/\/www.blizzarddigital.com\/blog\/html-5-microdata-and-you\/","title":{"rendered":"HTML 5, Microdata, and You"},"content":{"rendered":"<p>Howdy, everybody. I have finally returned to convey some more information regarding the technical side of web design. Today&#8217;s topic is HTML5 and microdata.<\/p>\n<p>I have recently begun using HTML 5 instead of XHMTL 1.0. The spec for HTML 5 is still a long way off from being a W3 &#8220;recommendation,&#8221; but I decided to switch to it because of &#8220;microdata&#8221;. Microdata, or Rich Snippets as Google calls them, are a way to mark up the information on your web site to be more machine readable, such as products or addresses. For example, you can use it to tell search engines that a portion of your page pertains to a specific product, pointing out exactly what makes up the name of the product, the price, its image, and so on. The following code example is pretty typical for an individual product&#8217;s info (obviously simplified for this example):<\/p>\n<p><code><\/p>\n<pre>\r\n&lt;div class=\"product\"&gt;\r\n\t&lt;div class=\"name\"&gt;The Web Site Maker&lt;\/div&gt;\r\n\t&lt;div class=\"price\"&gt;$99.99&lt;\/div&gt;\r\n\t&lt;div class=\"description\"&gt;This is the incredible Web Site Maker. No longer\r\n\t\tdo you have to get your hands dirty. This software contains a single\r\n\t\tbutton. Push to receive web site.&lt;\/div&gt;\r\n\t&lt;img src=\"web-site-maker.png\" alt=\"The Web Site Maker\" \/&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p><\/code><\/p>\n<p>However, a search engine doesn&#8217;t necessarily know what all that means. Google&#8217;s pretty scary and can probably decipher all that, but, with microdata, we can help by marking exactly what each bit of info means. As follows:<\/p>\n<p><code><\/p>\n<pre>\r\n&lt;div class=\"product\" <strong>itemscope=\"itemscope\" itemtype=\"http:\/\/schema.org\/Product\"<\/strong>&gt;\r\n\t&lt;div class=\"name\" <strong>itemprop=\"name\"<\/strong>&gt;The Web Site Maker&lt;\/div&gt;\r\n\t&lt;div class=\"price\" <strong>itemprop=\"offers\"<\/strong> <strong>itemscope=\"itemscope\"<\/strong>\r\n\t\t<strong>itemtype=\"http:\/\/schema.org\/Offer\"<\/strong>&gt;<strong>&lt;span itemprop=\"price\"&gt;<\/strong>\r\n\t\t$99.99<strong>&lt;\/span&gt;<\/strong>&lt;\/div&gt;\r\n\t&lt;div class=\"description\" <strong>itemprop=\"description\"<\/strong>&gt;This is the incredible Web Site\r\n\t\tMaker. No longer do you have to get your hands dirty. This software\r\n\t\tcontains a single button. Push to receive web site.&lt;\/div&gt;\r\n\t&lt;img <strong>itemprop=\"image\"<\/strong> src=\"web-site-maker.png\" alt=\"The Web Site Maker\" \/&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p><\/code><\/p>\n<p>What is this <code>itemscope<\/code> and <code>itemtype<\/code> stuff, you may be wondering. These are attributes new to HTML 5, and thus the reason for switching to it. These attributes are legal on nearly any element and are used to mark up our data. The <code>itemscope<\/code> attribute is used to mark an element as the container for a particular item&mdash;in this case, a product. In the example, it means everything inside the element with the <code>itemscope<\/code> attribute is information about this particular product. It&#8217;s within the &#8220;scope&#8221; of this product. As an aside, you may notice that <code>itemscope<\/code> &#8220;equals&#8221; <code>itemscope<\/code> in the example. This is only because I am using the XHTML flavor of HTML 5. If you were using the HTML variant, you could just use <code>itemscope<\/code> on its own without the <code>=\"itemscope\"<\/code> portion.<\/p>\n<p>After <code>itemscope<\/code> comes <code>itemtype=\"http:\/\/schema.org\/Product\"<\/code>. As the name implies, it specifies the type of item for the machine reader to expect. &#8220;Product&#8221; is one of a plethora of types you can use, a list of which can be found at <a href=\"http:\/\/schema.org\">Schema.org<\/a>.<\/p>\n<p>Moving on, <code>itemprop=\"name\"<\/code> obviously specifies the name of the product. &#8220;Name&#8221; is a property of the &#8220;Product&#8221; type. The Schema.org web site shows in detail the properties of each type, usually with examples, under their <a href=\"http:\/\/schema.org\/docs\/schemas.html\">schemas section<\/a>. Some properties, however, are more than a simple text value. Some are actually an <code>itemtype<\/code> of their own, such as the price of the product. It is not merely an <code>itemprop=\"price\"<\/code> with a number inside, but an &#8220;Offer&#8221; type. So it is necessary to again add the <code>itemscope<\/code> and <code>itemtype<\/code> attributes. I also had to add an extra element&mdash;the <code>span<\/code>&mdash;inside the price <code>div<\/code> so I could apply the &#8220;price&#8221; property, a property of &#8220;Offer&#8221;.<\/p>\n<p>The rest of the example is just made up of some additional <code>itemprop<\/code> attributes. After you&#8217;ve marked up your information, you can use <a href=\"http:\/\/www.google.com\/webmasters\/tools\/richsnippets\">Google&#8217;s Rich Snippets Testing Tool<\/a> to make sure it&#8217;s marked up correctly.<\/p>\n<p>If you&#8217;re already using some form of XHTML, it should be a pretty simple matter of changing the doctype and replacing your <code>&lt;meta http-equiv=\"content-type\" content=\"mime-type; charset=utf-8\" \/&gt;<\/code> (or whatever you may be using) with a simple <code>&lt;meta charset=\"UTF-8\" \/&gt;<\/code> to convert to valid HTML 5. It&#8217;s not necessary to use the new elements such as <code>header<\/code> or <code>section<\/code>. Your old <code>div<\/code> elements will work fine. It&#8217;s probably not even desirable at this point to utilize the new elements thanks to the inability of Internet Explorer 8 and lower to display them without a <a href=\"http:\/\/remysharp.com\/2009\/01\/07\/html5-enabling-script\/\">hack<\/a>.<\/p>\n<p>Welcome to the future. I hope you can start using microdata (AKA Rich Snippets) to make the web a more semantic place. Don&#8217;t forget to check out <a href=\"http:\/\/schema.org\/\">Schema.org<\/a> for all the supported types and their properties. Have fun, web wizards!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Howdy, everybody. I have finally returned to convey some more information regarding the technical side of web design. Today&#8217;s topic is HTML5 and microdata. I have recently begun using HTML 5 instead of XHMTL 1.0. The spec for HTML 5 is still a long way off from being a W3 &#8220;recommendation,&#8221; but I decided to [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,7],"tags":[178,175,180,179,176,177,154,6],"class_list":["post-935","post","type-post","status-publish","format-standard","hentry","category-seo","category-web-standards","tag-html-5","tag-html5","tag-micro-data","tag-microdata","tag-rich-snippets","tag-schema","tag-semantics","tag-web-design"],"_links":{"self":[{"href":"https:\/\/www.blizzarddigital.com\/blog\/wp-json\/wp\/v2\/posts\/935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blizzarddigital.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blizzarddigital.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blizzarddigital.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blizzarddigital.com\/blog\/wp-json\/wp\/v2\/comments?post=935"}],"version-history":[{"count":31,"href":"https:\/\/www.blizzarddigital.com\/blog\/wp-json\/wp\/v2\/posts\/935\/revisions"}],"predecessor-version":[{"id":971,"href":"https:\/\/www.blizzarddigital.com\/blog\/wp-json\/wp\/v2\/posts\/935\/revisions\/971"}],"wp:attachment":[{"href":"https:\/\/www.blizzarddigital.com\/blog\/wp-json\/wp\/v2\/media?parent=935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blizzarddigital.com\/blog\/wp-json\/wp\/v2\/categories?post=935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blizzarddigital.com\/blog\/wp-json\/wp\/v2\/tags?post=935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}