Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New rule: Always specify the mime type of the resource in the <source> tag #6

Open
JulienWilhelm opened this issue Jul 18, 2024 · 0 comments
Assignees
Labels
💡 rule-idea Rule not already specified, but a good starting point

Comments

@JulienWilhelm
Copy link

JulienWilhelm commented Jul 18, 2024

The <source> tag can be used with the <video>, <audio> and <picture> tag to provide several file formats depending on browser support.

The "type" attribute is used to indicate to the browser the mime type of the resource. If this attribute is not specified, the browser will have to communicate with the server, or even download the resource, to determine if it can support it.

The MDN French translation about the "type" attribute is very clear:

Le type MIME de la ressource, éventuellement complété d'un paramètre codecs. La RFC 4281 indique comment indiquer des codecs. Si l'attribut type n'est pas défini, le type de média est récupéré depuis le serveur et le navigateur vérifie s'il peut le gérer. Si le fichier ne peut être utilisé, la source suivante est contrôlée et ainsi de suite. Si l'attribut type est indiqué, le navigateur le compare avec la liste des types qu'il prend en charge, si le type n'est pas reconnu, le serveur n'est pas interrogé et le navigateur analyse l'élément qui suit.

The "type" attribute should therefore always be specified.

<!-- Bad: "type" is not specified. -->
<video>
	<source src="path/to/video.webm">
	<source src="path/to/video.m4v">
</video>
<!-- Good: "type" is specified. -->
<video>
	<source src="path/to/video.webm" type="video/webm">
	<source src="path/to/video.m4v" type="video/mp4">
</video>
@olegoaer olegoaer added the 💡 rule-idea Rule not already specified, but a good starting point label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 rule-idea Rule not already specified, but a good starting point
Projects
None yet
Development

No branches or pull requests

3 participants