Visit DynamiX Web Design! E-Mail DynamiX Web Design!

html: embedding a YouTube video using xtml strict code

If you’ve ever tried to add a YouTube video to your web site, you’ve probably found that it’s not too hard to do. But adding one that validates as XHTML Strict is just a little bit tougher. Let’s go step by step.

Step 1: Get the code.

YouTube has a very convenient “Embed” section on every video they host, which allows you to very easily get the code you need to post a video on your web site or blog. Unfortunately, the code they give you will throw XHTML validation errors.

Example YouTube Code:<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/Pk7yqlTMvp8&rel=1"> </param><param name="wmode" value="transparent"> </param><embed src="http://www.youtube.com/v/Pk7yqlTMvp8&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>

This code will work, but it will throw 15 errors (see our example page for a full list of errors). Now, how do we remedy this? Very simply.

Our Example Code:<object type="application/x-shockwave-flash" width="425" height="355" data="http://www.youtube.com/v/Pk7yqlTMvp8"><param name="movie" value="http://www.youtube.com/v/Pk7yqlTMvp8" /></object>

This will work just as well as what YouTube provides, but with less code and with no validation errors. To make this code work for your video, simply replace the “Pk7yqlTMvp8″ in the code with the one provided by YouTube.

See it in action!



Want to see more about how we did this? Simply check out our example page! If you are interested in learning more about how to utilize YouTube in your business, please take a look at our sister article entitled A quick look: YouTube and what it could mean for your business

Compatibility:
This method has been tested in and is compatible with Internet Explorer 5.5, 6, 7, Firefox (PC and Mac), Netscape and Safari (PC and Mac).

That’s all folks!

If you have an idea or article that you would like to contribute, send it on! We’re always looking for good, quality articles. Note that we will not republish an article that has been published elsewhere, so keep it original!

del.icio.us Reddit Slashdot Digg Facebook Technorati Google StumbleUpon Furl Netscape Yahoo BlinkList Feed Me Links Bloglines Ask Mister Wong Newsvine Wink Squidoo Fark Blogmarks Sphere

Tags: , ,

4 Responses to “html: embedding a YouTube video using xtml strict code”

  1. EricNo Gravatar Says:

    Thats a pretty funny video!

  2. Uploaded site different from local site - Webforumz.com Says:

    Webforumz.com has linked to this article on their web site.

  3. JamesNo Gravatar Says:

    Good stuff! I was stumped on how to get my page valid in xhtml strict with a YouTube vid.

  4. DynamiXLabsNo Gravatar Says:

    Happy to help! Thanks for your kind comment.

We want your feedback! Leave us your thoughts below.



Interested in hiring the DynamiX Web Design team for one of your projects? Give us a ring!
Add to Technorati Favorites

Copyright © 2008 DynamiX Web Design, LLC.  |  DynamiX Labs is proudly powered by WordPress

Entries (RSS) & Comments (RSS).  |  thanks & about.
The DynamiX Mascot button submit it!
hire dynamix!