Youtube Valid XHTML Embed Code

By default, Youtube embed code provided by youtube is not passed XHTML validation . Go to www.validator.w3.org to check your website.

The image shown below is a prove of the invalid Youtube xhtml embed code:

youtube not passed markup validation

The invalid Youtube embed code source is shown below:

youtube not valid xhtml code

Above code is automatically generated by Youtube and WordPress after you change the editor form from html mode then visual mode and then back yo html mode again.

Then, how to make Youtube html code passed the xHTML markup validation like below image..? 🙂

youtube valid xhtml markup

Here is the answer…. To make Youtube code become valid xhtml, you should use this code for your video:

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

Notes:
The code “7_6B6vwE83U” is the video code number.

For example:
Youtube video you want to show on you website is “http://www.youtube.com/watch?v=TT2wNCqwa8I“, then you should change 7_6B6vwE83U to become TT2wNCqwa8I

If you’re a blogger and use WordPress or other blog cms which support Visual Editor, do not change the editor to visual mode. Use html mode… WordPress will automatically change the above code to the default code for youtube video. So, you must click the “Publish” button when your editor is in html mode.

youtube valid xhtml code

Done, you have Youtube valid xhtml 🙂

2 thoughts on “Youtube Valid XHTML Embed Code

  1. I have been looking for a solution to this problem for some time, and here it is! And so easy! Thank you! Moving on to next validation issue… 😉

Leave a Reply