Total posts 6
Total comments 19

Embedding YouTube Videos as Valid XHTML

   October 6th, 2007

If you’ve ever validated an otherwise XHTML 1.0 compliant website that embedded a video from YouTube, you’ve probably seen validation errors related to YouTube’s use of the <embed> tag, which has been deprecated in XHTML 1.0.

If you’re looking to embed a YouTube video in your website’s code and want to retain your validity, instead of using their suggested format:

 <object width="425" height="350">
    <param name="movie" value="http://www.youtube.com/v/7_6B6vwE83U">
    </param>
    <embed xsrc="http://www.youtube.com/v/7_6B6vwE83U"
      mce_src="http://www.youtube.com/v/7_6B6vwE83U"
      type="application/x-shockwave-flash" width="425" height="350">
    </embed>
  </object>

Use the following format:

 <object type="application/x-shockwave-flash"
    style="width:425px; height:350px;"
    data="http://www.youtube.com/v/7_6B6vwE83U>
    <param name="movie" value="http://www.youtube.com/v/7_6B6vwE83U" />
  </object>

You’ll notice that the new format leaves out the <embed> tag and still functions correctly when embedded in your web page.

No Comments ยป