Talk to us today 0845 86 22 122

Blog.

15th February 2010 |  Written by Dave Ashworth

Tips When Embedding a YouTube Video

More often than not it is preferable to embed a YouTube video into your page content, as opposed to linking off to YouTube and taking visitors away from your site, below are some tips on how to do this:

Valid HTML

First off, it does annoy me (it really does) that the embed code that YouTube provide for each video is invalid HTML, so, here is W3C valid HTML you should use:

<object height=”your_width” width=”your_height” type=”application/x-shockwave-flash” data=”the_embed_url_not_the_page_url“>
<param name=”movie” value=”the_embed_url_not_the_page_url” />
<param name=”FlashVars” value=”playerMode=embedded” />
</object>

Note, you must use the embed URL provided by YouTube here and not the standard link.

Turn Off Related Videos

When the video has finished playing, by default it will then show you related videos.  This can be an issue if, for example, the video on your website then shows related videos that link to a competitor’s videos.  To get around this, you simply append &rel=0 to the end of the URL:

http://www.youtube.com/v/cpRPin0yPHU&hl=en_GB&fs=1&rel=0

Autoplay

If you want the video to start automatically playing when the page is accessed, simply append &autoplay=1 to the URL.

http://www.youtube.com/v/cpRPin0yPHU&hl=en_GB&fs=1&autoplay=1

Deep Linking

As an aside, if you ever want to link to a YouTube video, but want to access a video at a certain point, you can add minute and seconds parameters to do just  that, so, whereas normally you’d send a link such as:

http://www.youtube.com/watch?v=SKgCXWGM3wY

and say “watch this for the greatest free kick you’re ever likely to see, but if you don’t want to watch highlights of a great game then spin on to about 4m40″, you can now just send the following link:

http://www.youtube.com/watch?v=SKgCXWGM3wY#t=4m47s

You just need to amend the minutes and seconds accordingly, it’s that easy.

Your Comments

  1. another useful one is to hide the title and rating of the embedded video by inserting &showinfo=0

  2. Good tip Alex, thanks for that, will come in handy.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>