mdn / content

The content behind MDN Web Docs
https://developer.mozilla.org
Other
9.15k stars 22.46k forks source link

What characters are allowed in a class name? #34253

Closed boxcleverliam closed 2 months ago

boxcleverliam commented 3 months ago

MDN URL

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class

What specific section or headline is this issue about?

The main discription of the class attribute

What information was incorrect, unhelpful, or incomplete?

I think that "space-separated list" is not a clear enough description of what the value can be. Can it include any non-space unicode character? There is a link to the specification, but it is necessary to follow a second link after that to find this information.

What did you expect to see?

The actual rules, plus some guidance on best practices. For example: A space-separated list of tokens, each consisting of any character other than a space. For maximum compatibility, it may be recommended to use only letters, numbers, dashes and underscores.

Do you have any supporting links, references, or citations?

Link in article to spec: https://html.spec.whatwg.org/multipage/dom.html#global-attributes:classes-2 Extra links found in the spec, when read together gives a more complete answer https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#set-of-space-separated-tokens https://infra.spec.whatwg.org/#ascii-whitespace

Do you have anything more you want to share?

I encountered the class name "N/A" in the wild, and I came to MDN to find out if it is a valid class name.

MDN metadata

Page report details * Folder: `en-us/web/html/global_attributes/class` * MDN URL: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class * GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/html/global_attributes/class/index.md * Last commit: https://github.com/mdn/content/commit/ba96f2f183353872db6d9242c7d2dffe2dbc0c35 * Document last modified: 2023-02-24T05:52:35.000Z
Josh-Cena commented 3 months ago

https://github.com/mdn/content/issues/28752 is very related. Short answer is most characters are accepted but some make your life harder. Long answer should be put into the docs.