Possible error: Video element with source inside P

For technical support and bug reports for all editions of CSS HTML Validator, including htmlval for Linux and Mac.
Post Reply
TomHTML
Rank III - Intermediate
Posts: 75
Joined: Sun Feb 04, 2018 10:19 am

Possible error: Video element with source inside P

Post 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!
User avatar
Albert Wiersch
Site Admin
Posts: 3800
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Possible error: Video element with source inside P

Post 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).
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
TomHTML
Rank III - Intermediate
Posts: 75
Joined: Sun Feb 04, 2018 10:19 am

Re: Possible error: Video element with source inside P

Post by TomHTML »

Many thanks!
Post Reply