Valid Characters for HTML Attributes

I was working on something today and was wondering if this

<div data-some.weird.custom.attribute></div>

was valid html. Turns out it is, along with a bunch more of other weird options. I found the following details here:

In short, a HTML attribute name can be:

  • First character is a letter, the underscore “_”, or colon “:” (oddly!)
  • Additional (optional) characters can be: a letter, a digit, underscore, colon, period, dash, or a “CombiningChar” or “Extender” character, which I believe allows Unicode attributes names.

Pretty cool…


Leave a Reply

Spam protection by WP Captcha-Free