Skip to content

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

@Kainkainkain

Description

@Kainkainkain

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions