views:

117

answers:

3

While validating my not be a big issue to some people, I personally want my page to validate whenever possible, as I feel it's a good habit to code properly whether the compiler/browser/person reading your code understands anyways.

Anyways, I'm building a website for a client that is requesting a YouTube video of theirs be embedded in the page. Easy, I grab the code from YouTube and throw it in the page. It works of course, but the page now doesn't validate under XHTML 1.0 Strict solely because of the YouTube-generated code.

The part that doesn't validate is the embed portion, and it works fine without this line in Chrome, but breaks in Firefox/IE. If it was just IE I'd just shrug it off as IE being terrible as per usual, but being as Firefox is doing it as well I'm wondering how to approach the situation. I could just dynamically input the content based on the browser, therefore validating, but that seems sloppy.

Am I fighting a losing battle and should just ignore the fact that this page doesn't validate because of this snippet?

Not actual video, just example code

<object width="480" height="385">
<param name="movie" value="http://www.youtube.com/v/oHg5SJYRHA0?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/oHg5SJYRHA0?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed>
</object>
A: 

I think if you use swfobject you could get it to validate.

http://code.google.com/p/swfobject/

fehays
A: 

The <embed> tag is new to HTML5 and it's quite possible that the validator you are using is not fully up-to-date. All of that code should be quite fine in XHTML 1.0 strict.

Moses
I used http://validator.w3.org/, the error is not that the embed tag is invalid, but that the attributes are invalid.
Robert
+1  A: 
<object type="application/x-shockwave-flash"
    data="http://www.youtube.com/v/oHg5SJYRHA0?fs=1&amp;amp;hl=en_US"
    width="480" height="385">
  <param name="movie"
      value="http://www.youtube.com/v/oHg5SJYRHA0?fs=1&amp;amp;hl=en_US"/&gt;
  <param name="allowFullScreen" value="true"/>
  <param name="allowscriptaccess" value="always"/>
</object>

That should work on IE, Firefox, Opera, Safari and Chrome.

The data attribute of <object> and the movie parameter must both be present and must have the same value.

In IE this prevents the SWF from streaming and, for example, presenting a pre-loader, but that should be a non-issue for YouTube.

For more, and for a fix for that last problem, see Flash Satay: Embedding Flash While Supporting Standards.

Daniel Cassidy