How to make HTML embed code from YouTube W3C compliant?
Here is an example of the embed code from a Youtube Video:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//E开发者_如何学CN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>I AM YOUR DOCUMENT TITLE REPLACE ME</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
</head>
<body>
<div>
<object width="1280" height="750">
<param name="movie" value="https://www.youtube-nocookie.com/v/WZ-1lfammjk?fs=1&hl=en_US&rel=0"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="https://www.youtube-nocookie.com/v/WZ-1lfammjk?fs=1&hl=en_US&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="1280" height="750"></embed>
</object>
</div>
</body>
</html>
I made this go through the W3C HTML 4.01 Strict validator, and got the following errors:
Line 13, Column 115: end tag for element "PARAM" which is not open
Line 14, Column 55: end tag for element "PARAM" which is not open
Line 15, Column 59: end tag for element "PARAM" which is not open
Line 16, Column 16: there is no attribute "SRC"
Line 16, Column 98: there is no attribute "TYPE"
Line 16, Column 148: there is no attribute "ALLOWSCRIPTACCESS"
Line 16, Column 173: there is no attribute "ALLOWFULLSCREEN"
Line 16, Column 186: there is no attribute "WIDTH"
Line 16, Column 200: there is no attribute "HEIGHT"
Line 16, Column 205: element "EMBED" undefined
What can I do to fix this? I have limited experience, so detailed answers would be great. Thanks!
It depends on what version you're validating for. To check your code, use the W3CValidation Service
Here is a direct link to validate just a portion of code.
EDIT
Try using this embed code instead:
<object type="application/x-shockwave-flash" style="width:425px; height:350px;" data="https://www.youtube-nocookie.com/v/WZ-1lfammjk?fs=1&hl=en_US&rel=0"><param name="movie" value="https://www.youtube-nocookie.com/v/WZ-1lfammjk?fs=1&hl=en_US&rel=0" /></object>
This embed code validated on HTML 4.01 Strict and HTML5 just fine.
Use this W3C validator. Make sure you validate it as an HTML fragment, not a whole document.
精彩评论