Embedding XHTML compliant Youtube videos

by David Alfaro 1. October 2008 05:16

What are we facing?

Youtube provides a code for embedding any video in my page, however the such a code is not XHTML 1.0 compliant. What is the generic way of making any Youtube video XHTML 1.0 compliant?

The Solution

The code given by Youtube for any video to be embedded in your page has the following format:

<object width="A" height="B">
   <param name="movie" value="C"></param>
   <embed src="C" type="application/x-shockwave-flash" width="A" height="B"></embed>
</object> 

Where A is the width, B is the height and C is the url's video source.

The XHTML 1.0 friendly version of that is in the following format:

<object type="application/x-shockwave-flash" style="width: Apx; height: Bpx;" data="C"> 
   <param name="movie" value="C" />
</object>

Is the display the same? Take a look (you can also see the source code in your browser)

Displaying with Youtube video code

Displaying with XHTML 1.0 compliant code

Don't you agree that a automated tool to do this would be a great idea? There are many scenarios when this is a "nice to have"

Some external references

Embedding YouTube Videos as Valid XHTML 1.0 of Bernie Zimmermann

YOUTUBE XHTML EMBED of Paimonia

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

standards

Comments