HTML5 Video Validation Error
I have the following markup, implemented using the VideoJS player (I can include the js too, if it becomes necessary):
<video id="example_video_1" class="video-js" width="736" height="352" controls="controls" autoplay="autoplay" loop="loop">
<source src="a/v/jt_homevid.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
<source src="a/v/jt_homevid.ogg" type='video/ogg; codecs="theora, vorbis"'>
<object id="flash_fallback_1" class="vjs-flash-fallback" width="736" height="352" type="application/x-shockwave-flash" data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />
<param name="allowfullscreen" value="true" />
<param name="flashvars" value='config={"playlist":["<? echo $currurl; ?>/a/v/slide-1-joshtaerk-cdcover.jpg", {"url": "<? echo $currurl; ?>/a/v/jt_homevid.mp4","autoPlay":false,"autoBuffering":true}]}' />
<img src="a/v/slide-1-joshtaerk-cdcover.jpg" width="736" height="352" alt="Poster Image" title="No video playback capabilities." />
</object>
</video>
And this is currently failing HTML validation, with the following error message:
Line 152, Column 82: Element source not allowed as child of element video in this context. (Suppressing further errors from this subtree.)…
Contexts in which element source may be used:As a child of a media element, before any flow content or track elements.Content model for element video:If the element has a src attribute: zero or more track elements, then transparent, but with no media element descendants.If the element does not have a src attribute: zero or more source elements, then zero or more track elements, then transparent, but with no media element descendants.
I do understand that I maybe should not be trusting the W3C HTML5 validator at this point in it's development, but if I have miscoded, I would like to identify where, and how to prevent it in the future. Also, I'd like to be sure I am interpreting the error message correctly, which I think should happen along the way.
I cannot see how I have deviated from the allowed contexts for this element. It is a child of a media element (Specifically the <video>
tag), it is before any 'flow content' I believe, because I cannot find the <source>
element listed as flow content on the W3C (at this link), and I do not have any <track>
elements currently.
One thing I'm not certain about is the definition of 'then transparent' in the content model for the <video>
element. From my understanding is that if elements inside the media elements are valid if they are also valid inside the parent of the media element (from this thread: Can I have multiple src attributes in an HTML5 <audio> element? Or an src attribu开发者_Go百科te and a <source> element?), and this is perhaps where I've misstepped, as I have the <video>
element inside a <div>
parent?
Can anyone confirm this as my mistake, or whether I should ignore the validation message? If this is a mistake, how else should I be laying out my content? By styling the video element directly?
Thanks in advance.
Your understanding is correct, and this does look like a validator bug.
Validator.nu, which is based on the same validator engine as the W3C validator, but is likely to be a later version, passes the mark-up without any errors.
In my case, I have this error
with this html code:
<video class="tab" controls>
Your browser does not support the <video> tag.
<source src="img/holsbeek-HD720p.mov" type="video/mp4" />
</video>
But not if the sequence is right:
<video class="tab" controls>
<source src="img/holsbeek-HD720p.mov" type="video/mp4" />
Your browser does not support the <video> tag.
</video>
This bug is now fixed in the HTML5 Validator.
精彩评论