Youtube recently added a new feature to the video player used to embed Youtube videos on other website.
The new default player, once the video completes playing, will display a list of related videos.
While this feature could be useful for some users it is probably not wanted on Youtube video aggregation websites.
Fortunately it’s possible to disable related videos.
Let’s see how.
The default player
Let’s take a cool video (I’m a windsurfing addicted).
The default embed code Youtube suggest us is
<object width="425" height="350"> <param name="movie" value="http://www.youtube.com/v/Yc_J_kXaFSw"></param> <param name="wmode" value="transparent"></param> <embed src="http://www.youtube.com/v/Yc_J_kXaFSw" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed> </object>
As you can see, at the end of the video the player will display something like this:

Disabling related videos
The trick is to attach to the player URL (http://www.youtube.com/v/Yc_J_kXaFSw) the rel=0 parameter.
The player URL will became http://www.youtube.com/v/Yc_J_kXaFSw&rel;=0
Just update the embed code with the new URL:
<object width="425" height="350"> <param name="movie" value="http://www.youtube.com/v/Yc_J_kXaFSw&rel=0"></param> <param name="wmode" value="transparent"></param> <embed src="http://www.youtube.com/v/Yc_J_kXaFSw&rel=0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed> </object>
Let’s use valid XHTML code
Unfortunately the embed code provided by Youtube isn’t valid XHTML code and does not pass the W3C’s XHTML validation.
This is really bad as creating valid XHTML web pages is valuable and professional. In some countries it is even required by law for public administration websites.
So we can use something like
<!--[if !IE]> <--> <object type="application/x-shockwave-flash" width="425" height="350" data="http://www.youtube.com/v/Yc_J_kXaFSw&rel=0"> <!--> <![endif]--> <!--[if IE]> <object type="application/x-shockwave-flash" width="425" height="350" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"> <![endif]--> <param name="movie" value="http://www.youtube.com/v/Yc_J_kXaFSw&rel=0" /> <p>Your browser is not able to display this multimedia content.</p> </object>
The above code, which come from my Drupal video module, is valid XHTML code and works with the most used web browsers.
The above code generate:
Conclusions
You are now able to control the behavior of Youtube player related video and post on your website Youtube videos following XHTML standards.