3

I don't understand this Error I am receiving from the W3C Validator.

Attribute “controlslist” not allowed on element “audio” at this point.

Here's my HTML (from Drupal 8):

<audio controls="" controlslist="nodownload"> <source src="/sites/default/files/audio/myfile.mp3" type="audio/mpeg"> </audio>

I added controlslist="nodownload" to hide the download button, and this code seems to be the same as the answer to remove the download button in Chrome.

So I don't understand the error I am getting; what does "at this point" mean? What do I have to do to pass the validation?

2
  • What is the DOCTYPE of your HTML document? Are you using HTML5? Commented Dec 27, 2020 at 21:26
  • Yes, HTML5. First two lines: <!DOCTYPE html><html lang="ja" class="js" dir="ltr" prefix="og: https://ogp.me/ns#"> Commented Dec 28, 2020 at 2:51

1 Answer 1

3

Because there is no controlslist attribute on the audio element in the current official HTML5 standard.

FWIW I can't find any mention of a controlslist attribute on the audio element. The linked question refers to a controlsList*1 attribute on the video element (although I would expect all media elements to share the same attributes).

(*1 The linked question uses a capital "L" in "List", throughout the page, perhaps reflecting the JS property name, although the HTML attribute would be case-insensitive.)

The Mozilla.org docs for the audio element have no mention of a controlslist attribute. However, for the video element they do list a controlslist attribute, but it is listed as:

This is an experimental API that should not be used in production code.

So, it would seem this is an "experimental" feature which has (as yet) spotty browser support (notably missing from Firefox 84-86, Safari 14, iOS Safari and Firefox Android 83 and... IE11). However, browser's that don't support this may not offer a download button anyway (I don't know - I've not looked into this). As always, test test test in the browsers you intend to support.

Consequently, if you want to use this attribute then you'll have to sacrifice W3C validation.

2
  • Ah ok, that makes sense. I thought "at this point" meant at this point on the page (but you can put it somewhere else and it will work), but what it really meant is at this point in time. Thank you for clarifying that badly worded warning. Commented Dec 28, 2020 at 18:32
  • "I thought "at this point" meant at this point on the page" - yes, that is exactly what it does mean. But that doesn't necessarily mean that it's valid anywhere else either. I'm not sure why the validator clarifies this message with "at this point". If you use any invalid attribute on a valid element then you get the same wording in the error message with the HTML5 validator. (The older HTML 4.01 validator did not include "at this point" in similar errors.)
    – MrWhite
    Commented Dec 28, 2020 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.