Page 1 of 1

Possible error: Video element with source inside P

Posted: Wed Jan 25, 2023 3:45 pm
by TomHTML
When validating this code:

Code: Select all

<p>
	<video autoplay="" playsinline="" loop="" muted="" title="Animation">
		<source src="my-video.webm" type="video/webm">
		<source src="my-video.mp4" type="video/mp4">
		<source src="my-video.ogv" type="video/ogg">
	</video>
</p>
The current 2023 validator complains:
The <source> element cannot be used here (in <video> which is in <p>). This is because the <video> element can contain transparent content. In this case <video>'s allowed content is determined by its ancestor <p> element, and <p> cannot contain <source>.
But the Nu HTML checker validates this.

This Stackoverflow Post explains that <video> is categorized as phrasing content (with links to the W3 docs), and all phrasing content is allowed inside <p>. Since <source> elements are integral children to <video> elements, it'd seem that <video> elements with embedded <source> elements are valid inside <p> elements.

Perhaps the validator is incorrect? Please advise.

Many thanks!

Re: Possible error: Video element with source inside P

Posted: Wed Jan 25, 2023 5:23 pm
by Albert Wiersch
Hi Tom,

Thank you for reporting this. This looks like a bug in CSS HTML Validator. Sorry about that.

The stackoverflow post is rather old. The current spec for <video> is at https://html.spec.whatwg.org/multipage/ ... eo-element

I'm going to have to rework the content model checking for <video> in an update.

For now I have disabled the checking that is causing this problem in the latest 2023/v23 config file which you can download here if you want:
https://www.htmlvalidator.com/2023/htmlvalV230cfg.zip

Please see the "readme" file in the above ZIP file for installation instructions.

UPDATE: Should be fixed in v23.0020+. The new/updated config file disables the buggy content checking for <audio> and <video> elements and enables the fixed checking if using v23.0020 or above (which is not yet released).

Re: Possible error: Video element with source inside P

Posted: Wed Jan 25, 2023 6:18 pm
by TomHTML
Many thanks!