Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get YouTube's embed code validate against HTML5?

My page validated error free against HTML5 until I added YouTube's embed code.

# Line 140, Column 132: Stray end tag param.

    …O30JM&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="tru

# Error Line 140, Column 183: Stray end tag param.

    …llowFullScreen" value="true"></param><param name="allowscriptaccess" value="a

# Error Line 140, Column 238: Stray end tag param.

    …scriptaccess" value="always"></param><embed src="http://www.youtube.com/v/1rW

# Error Line 140, Column 430: Stray end tag embed.

    …ways" allowfullscreen="true"></embed></object>

Is there a way to get object, embed and param tags validate against HTML5 ?

like image 830
anjanesh Avatar asked Dec 07 '25 10:12

anjanesh


2 Answers

Remove the end tags and replace them with self closing tags.

Eg.

<embed ...></embed>

<embed ... />

Adding to Charlies answer, with some more detail:

Embed is a void element, i.e. it can have no content. Thus, it must not have closing tag, in the HTML serialization.

In the XHTML serialization it must be closed. XML parsers do not differentiate between self-closing tags and tags that are immediately (no white space) followed by a closing tag. But the latter is redundant and error prone, since white-space so easily slip in between the starting tag and the closing tag.

It may be written using the self-closing syntax, in the HTML serialization, which some authors, myself included, prefer as a style convention. It is ignored by the parsers, though.

Thus, the self closing syntax is always allowed on void elements, but sometimes redundant.

http://dev.w3.org/html5/markup/syntax.html#syntax-elements

like image 39
itpastorn Avatar answered Dec 10 '25 00:12

itpastorn