HTML Validation, Google, Amazon

Perm url with updates: http://xahlee.org/js/html_validation_google_amazon.html

HTML Validation, Google, Amazon

Xah Lee, 2011-01-22

More HTML validation Pain.

Here's a amazon ad widget from Amazon Associate site:

<iframe
src="http://rcm.amazon.com/e/cm?t=xyzxyz-20&o=1&p=11&l=ur1&category=textbooks&banner=17P1AE8RQ1T7ZFC62V82&f=ifr"
width="120"
height="600"
scrolling="no"
border="0"
marginwidth="0"
style="border:none;"
frameborder="0">
</iframe>

Of course it is not valid html. The ampersand needs to be &amp;. Also, there's no border="0" attribute for “iframe” tag.

Well, google isn't doing much better. Here's the code given by youtube for embedding a video:

<iframe
title="YouTube video player"
class="youtube-player"
type="text/html"
width="640"
height="390"
src="http://www.youtube.com/embed/nnsSUqgkDwU"
frameborder="0"
allowFullScreen>
</iframe>

“iframe” tag doesn't have the “type” attribute type="text/html", and there's no such thing as “allowFullScreen”.

How bad can it be? So, from these 2 sites alone, handling out bad code, are directly responsible for millions of site being invalid html. Of course, all other video sites all hand out invalid html. None gives correct html as far as i know. (See: How to Embed Video with Valid HTML.)

In the Google case, am sure they are just trying to solve a practical problem, though, i'm not sure it is absolutely necessary to resort to using invalid attributes. Clearly, the “allowFullScreen” is there to be parsed by javascript. If so, then it could easily be a comment tag instead, e.g.: <iframe ...><!-- allowFullScreen --></iframe>. And am not too sure that type="text/html" there is really necessary.

Popular posts from this blog

Browser User Agent Strings 2012

11 Years of Writing About Emacs

does md5 creates more randomness?