Jul
15
15
Making YouTube Videos XHTML Valid
Filed under: Asides | Tags: code, XHTML valid | July 15th, 2010
Sometime ago I found that my sight wasn’t XHTML valid. The problem was that YouTube video embed code is not XHTML valid. A search led me to this sight. It is easier than it looks. You just remove unnecessary code and rearrange what is left.
This is what you get from YouTube:
<object width="640" height="385"><param name="movie" value=
"http://www.youtube.com/v/3mvHYMcnSec&hl=en_US&fs=1?rel=0"></param>
<param name="allowFullScreen" value="true"></param><param name=
"allowscriptaccess"value="always"></param><embed>src=
"http://www.youtube.com/v/3mvHYMcnSec&hl=en_US&fs=1?rel=0" type=
"application/x-shockwave-flash" allowscriptaccess="always"
allowfullscreen="true" width="640" height="385"></embed></object>
This is what you change it to:
<div class="YTvideos"> <object type="application/x-shockwave-flash"
data="http://www.youtube.com/v/3mvHYMcnSec&hl=en_US&fs=1?rel=0">
<param name="movie" value="http://www.youtube.com/v/3mvHYMcnSec&hl
=en_US&fs=1?rel=0" /> <param name="allowFullScreen" value="true" />
</object> </div>
I leave the script that follows the URL and the full screen parameter.
Add this to your css:
.YTvideos object{
width:640px;
height:385px;
}
Set the dimensions to what your embed requires. You can have videos of various sizes on your site by setting up different classes, one for each size. These few changes result in XHTML validity.
Possibly Similar Posts:
- Eric Clapton: Everyday I Have the Blues
- This Week—Tragedy And Rudeness
- Americans For The Arts Honors Salman Rushdie
- Ryan Bingham — The Weary Kind
- Sherlock Holmes Premiere — New York
