-1
<button type="button"
oneclick="document.getElementById('a').style.visibility='visible'">
Click
</button>
<img id="a" style="visibility:hidden" src='pico.png' alt="src not found">

I mistyped "oneclick", but VS Code doesn't show me that. I was going crazy because I didn't find the error. Why? I already installed HTMLHint, HTML, CSS, Javascript extensions.

rioV8
  • 24,506
  • 3
  • 32
  • 49
Allexj
  • 1,375
  • 6
  • 14
  • 29
  • Duplicate of https://stackoverflow.com/questions/44559598/how-to-enable-vs-code-html-error-checking-validation – tbjgolden Mar 29 '22 at 10:43
  • @tbjgolden I just installed HTMLHint, but doesn't show me the error anyway. – Allexj Mar 29 '22 at 10:47
  • Is HTMLHint showing other errors besides the invalid attribute? – tbjgolden Mar 29 '22 at 10:49
  • What if you wanted an attribute named `oneclick` on your element that has `onclick` too? VSCode shouldn't worry about that. – maxshuty Mar 29 '22 at 10:49
  • @tbjgolden it shows warning about double quotes etc but doesn't show me the error related "oneclick" typo – Allexj Mar 29 '22 at 10:58
  • because `oneclick` is a valid attribute name, don't use `onclick` but attach event listeners. You are reading an old HTML book/article, don't hard code style attributes, give the tag a `class` and set the style in the CSS – rioV8 Mar 29 '22 at 13:12
  • @rioV8 — `oneclick` is not a valid attribute name. – Quentin Mar 29 '22 at 13:38
  • HTMLHint is a linting tool, not a validator. It doesn't have any features that check if attributes are valid for any given element. – Quentin Mar 29 '22 at 13:40
  • @Quentin It is a valid attribute name, only HTML5 does not have a meaning for it, if it was illegal then the HTML would not be rendered, or at least this tag, but that does not happen so it is valid, but I as programmer could attach any valid name (like `oneclick`) as attribute and query it and use it, (do something only on the first click). Most programmers use `data-*` names because they are reserved by W3 for the programmer, but that is all a convention. – rioV8 Mar 29 '22 at 15:59
  • @rioV8 — No. It is invalid. https://validator.w3.org/ will report it as an error. You have completely the wrong idea about how browsers handle errors in HTML markup. `data-*` attributes are **not** a convention, they are [the extension mechanism provided by the specification](https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes). – Quentin Mar 29 '22 at 16:04

2 Answers2

0

I've found this extension: umoxfo.vscode-w3cvalidation It works, you only have to setup the JAVA_HOME PATH.

Allexj
  • 1,375
  • 6
  • 14
  • 29
-1

I hope you are well You need to install the HTMLHint plugin and your problem will be solved Thanks

  • I just installed HTMLHint, but doesn't show me the error anyway. – Allexj Mar 29 '22 at 10:55
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 29 '22 at 12:36
  • HTMLHint is a linting tool, not a validator. It doesn't have any features that check if attributes are valid for any given element. – Quentin Mar 29 '22 at 13:40