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

w3C html spec compliance: custom attributes need a data- prefix. #119

Open
Kainkainkain opened this issue Sep 15, 2023 · 1 comment
Open

Comments

@Kainkainkain
Copy link

According to W3C specification, custom attributes should begin with "data-". This is part of HTML5 specification designed to allow web developers to use custom attributes where there's no existing attribute they could use. This helps in semantics, accessibility, etc., while also maintaining validity of the HTML document.

The attribute name should not contain any uppercase letters, and must be at least one character long after the prefix "data-". The attribute value can be any string.

Without the "data-" prefix, the HTML document would be considered invalid in HTML5 Doctype.

https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#embedding-custom-non-visible-data-with-the-data-attributes

Some clients, such as government, have a w3c compliance rules.
Also my linter doesnt like it.

if xyz attribute was simply updated to data-xyz it would be compliant.

I may be wrong, please correct me if anyone knows differing / newer specs.

@jtag05
Copy link

jtag05 commented Nov 26, 2023

Also my linter doesnt like it.

How I got here 😂
I fully support your points otherwise, too lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants