Author Archive

HTML 5, Microdata, and You

Howdy, everybody. I have finally returned to convey some more information regarding the technical side of web design. Today’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 “recommendation,” but I decided to switch to it because of “microdata”. 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’s info (obviously simplified for this example):

<div class="product">
	<div class="name">The Web Site Maker</div>
	<div class="price">$99.99</div>
	<div class="description">This is the incredible Web Site Maker. No longer
		do you have to get your hands dirty. This software contains a single
		button. Push to receive web site.</div>
	<img src="web-site-maker.png" alt="The Web Site Maker" />

However, a search engine doesn’t necessarily know what all that means. Google’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:

<div class="product" itemscope="itemscope" itemtype="">
	<div class="name" itemprop="name">The Web Site Maker</div>
	<div class="price" itemprop="offers" itemscope="itemscope"
		itemtype=""><span itemprop="price">
	<div class="description" itemprop="description">This is the incredible Web Site
		Maker. No longer do you have to get your hands dirty. This software
		contains a single button. Push to receive web site.</div>
	<img itemprop="image" src="web-site-maker.png" alt="The Web Site Maker" />

What is this itemscope and itemtype 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 itemscope attribute is used to mark an element as the container for a particular item—in this case, a product. In the example, it means everything inside the element with the itemscope attribute is information about this particular product. It’s within the “scope” of this product. As an aside, you may notice that itemscope “equals” itemscope 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 itemscope on its own without the ="itemscope" portion.

After itemscope comes itemtype="". As the name implies, it specifies the type of item for the machine reader to expect. “Product” is one of a plethora of types you can use, a list of which can be found at

Moving on, itemprop="name" obviously specifies the name of the product. “Name” is a property of the “Product” type. The web site shows in detail the properties of each type, usually with examples, under their schemas section. Some properties, however, are more than a simple text value. Some are actually an itemtype of their own, such as the price of the product. It is not merely an itemprop="price" with a number inside, but an “Offer” type. So it is necessary to again add the itemscope and itemtype attributes. I also had to add an extra element—the span—inside the price div so I could apply the “price” property, a property of “Offer”.

The rest of the example is just made up of some additional itemprop attributes. After you’ve marked up your information, you can use Google’s Rich Snippets Testing Tool to make sure it’s marked up correctly.

If you’re already using some form of XHTML, it should be a pretty simple matter of changing the doctype and replacing your <meta http-equiv="content-type" content="mime-type; charset=utf-8" /> (or whatever you may be using) with a simple <meta charset="UTF-8" /> to convert to valid HTML 5. It’s not necessary to use the new elements such as header or section. Your old div elements will work fine. It’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 hack.

Welcome to the future. I hope you can start using microdata (AKA Rich Snippets) to make the web a more semantic place. Don’t forget to check out for all the supported types and their properties. Have fun, web wizards!

—Kyle Blizzard

Valid Flash Embed and Preloaders Episode V: Internet Explorer Strikes Back

If you saw my previous post on valid Flash embed while maintaining preload functionality and used it, be warned: when the user does not have Flash, a lovely <![endif]--> will appear in IE where the Flash movie would normally be. The only way around it I’ve found is to actually duplicate everything from the opening object tag to the closing one so there is one each for IE and Firefox. For example:

<!--[if !IE]>-->
<object data="movie.swf" type="application/x-shockwave-flash" width="725" height="235">
	<param name="movie" value="movie.swf" />
<!--[if IE]>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="725" height="235">
	<param name="movie" value="movie.swf" />

Definitely a pain, but I’ve found no other way around it.

Also in my search for a solution, I discovered that our old pal Internet Explorer does not let you append anything but param elements to object elements in Javascript. That was pretty frustrating. Don’t try that. It doesn’t work.

—Kyle Blizzard

The Pesky iframe and XHTML Strict

Update: Example code updated. It used the shortened form of iframe before, as in <iframe />. That doesn’t sit well with IE. It now uses <iframe></iframe> which works. The same goes for object. It similarly does not play well with Firefox 4 (perhaps even lower versions) in shortened form.

If you’ve done much web work before, you’ve probably, at some time or another, had to use an iframe. It’s not pretty, but sometimes it’s the only choice, such as embedding a widget from another site or displaying things such as real estate listings. One of my biggest problems with it is that it doesn’t exist in the spec for XHTML Strict! It exists in Transitional, but I don’t like to use it. That may be good enough for some developers, but certainly not for me. How about you?

In Internet Explorer 8 (and possibly IE7, but I have not tested it) and Firefox, you can use the object element to embed a web page just like an iframe; however, IE gives it a thick, lovely border that seems impossible to remove. Here’s the trick: employing IE’s conditional comments, use an iframe for IE and an object for everything else. Here’s an example:

<!--[if !IE]><!--><object data="" type="text/html" width="320" height="240"></object>
<!--[if IE]><iframe frameborder="0" src="" width="320" height="240"></iframe>

Valid XHTML Strict! Make sure to keep your settings the same across both elements to keep it consistent.

Happy coding!

—Kyle Blizzard

Valid Flash Embed and Preloaders in Internet Explorer

Hello once again, web friends. Today I bring tidings of Flash preloaders and validity.

You may have noticed that with the embed code from my YouTube article that Flash movie preloaders don’t work in Internet Explorer, and the movie has to load entirely before it even displays at all. This is because Internet Explorer requires a different attribute and the removal of another in the object tag to let preloaders work properly. However, with different attributes, the Flash movie will not display at all in Firefox, so we must use Internet Explorer’s conditional comments to utilize two different opening object tags. Behold:

<!--[if !IE]>--><object data="yourmovie.swf" type="application/x-shockwave-flash"
	width="320" height="240"><!--<![endif]-->
<!--[if IE]><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
	width="320" height="240"><![endif]-->
	<param name="movie" value="yourmovie.swf" />
	<param name="quality" value="high" />

The first line is the original that works in both IE and Firefox but doesn’t allow preloaders in IE. The second is the IE-only method that works with preloaders. Note the lack of a data attribute and the addition of a classid attribute.

Well, there you have it. Venture forth and embed Flash validly with preload animations!

—Kyle Blizzard

Semantic Markup – Why Should You Use It?

Your markup should have meaning. Markup your content appropriately (e.g. put your address and phone number in the address element) and it becomes much more readable to search engines and other software used for data extraction. Using only div and span elements leaves much to be desired, semantically speaking. These elements are certainly indispensable, however, there are some cases where there are more meaningful elements to use. For example:

  • Use h1 as your page title; use h2 and on appropriately as sub-headings on the page. This provides an outline of your document.
  • Use lists (dl, ol, ul) instead of manually placing numbers or bullets.
  • Use address for any contact information on your page, including physical address, email address, phone numbers, and whatever else you would consider to be contact info.
  • Use table on data best represented in rows and columns. Use thead and th to markup the column headings and tbody for the data itself.

Check the HTML spec for additional meaningful elements and get to work! 🙂

You can use the W3’s handy Semantic Data Extractor tool to test your new semantic web site to give you an idea of how it would be seen by software.

That does it for now. See you next time! Until then, read SEO and Validation.

—Kyle Blizzard