Home About the Book About the Authors Handy Links

How to embed YouTube videos without invalid code

Miraz.

I’m developing a new blog and decided to check the validity of what I was doing. Once I recovered from the shock of 67 errors I realised that 2 embedded YouTube videos may well have been contributing problems. So I went searching and found this excellent advice:

If you’re looking to embed a YouTube video in your website’s code and want to retain your validity, … use the following

<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>

[Via : Embedding YouTube Videos as Valid XHTML 1.0, Bernie Zimmermann.]

Of course, you need to substitute the correct URL in two places.

In my new blog I fixed up a few other coding errors, used the above technique for the youTube videos and soon had the thrill of seeing the green ‘valid’ ribbon.