(You're browser does not support Cascading Style Sheets (CSS), the web standard used to format this web page. To see a full-format version of this web page, you will need to upgrade to a newer version of your browser. Or, download the most recent version of the Firefox browser at www.Mozilla.org.)
Home | Publications | Links | Archive | Contact Me
 

Compliant HTML Code for Linking to YouTube Video

Too nervous about tomorrow's midterm elections to post anything substantive. So I've decided to post a very entertaining video from YouTube, instead.

This is the first time I've linked to YouTube. After I made the initial post, I noticed that the XHTML code that YouTube recommends to embed the video is not valid XHTML:

<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/v/KTCYLbFxTpI"></param>
<param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/KTCYLbFxTpI"
type="application/x-shockwave-flash" wmode="transparent" 
width="425" height="350">
</embed>
</object>

Bernie Zimmermann at bernzilla, however, proposes the following code, which does adhere to XHTML standards:

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

I tweaked Zimmerman's code just a bit so that the video image would be centered in the post box. To do that, I added a "class" called "centered" to the XHTML:

<object type="application/x-shockwave-flash" 
style="width:425px; height:350px;" 
data="http://www.youtube.com/v/KTCYLbFxTpI" class="centered">
<param name="movie" value="http://www.youtube.com/v/KTCYLbFxTpI"/>
</object>

And defined "centered" in the page's CSS file as:

object.centered 	{ display: block;
			margin-left: auto;
			margin-right: auto;
			margin-top: 1em;
			margin-bottom: 1em;
			border-style: none;
			}