Embedding YouTube Movies in XHTML

YouTube If you try to embed a YouTube-video in a XHTML 1.0 compliant website, you will get validations errors. This is caused by YouTube’s use of the <embed> tag, which has been deprecated in XHTML 1.0.

The standard YouTube code is:

To solve the validations errors we have to get rid of the deprecated <embed> tag.

Therefore we add a data attribute to the <object> tag. The following code is the most simple and will work in Opera and Firefox:

To get it working in MS Explorer we need to add a <param> tag with name and value attribute:

To autoplay a movie simply add “&autoplay=1” to the url:

Easy isn’t it? The code in xhtml is even shorter than the standard YouTube code.

Comments are closed.

Categories
Archives
Links