HTML: Custom Tag (Custom Element)

By Xah Lee. Date: .

The HTML standard has a concept of custom element. That is, any arbitrary tag (with some naming requirement), like this

<abc-xyz>custom element</abc-xyz>

you can use CSS to define its appearance and use JavaScript to define its behavior.

Custom element name requirement

All characters must be lowercase.

  1. Start with lowercase a to z
  2. Followed by zero or more simple Unicode character
  3. Followed by a hyphen
  4. Followed by zero or more simple Unicode character

the “simple Unicode character” includes Emoji 😄

custom element name spec 2022-08-24 cSgM4
custom element name spec 2022-08-24
HTML spec custom element name 2022-08-24
HTML spec custom element name 2022-08-24

Reference

https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements

HTML spec Custom Element 2022-08-24 6dNbf
HTML spec Custom Element 2022-08-24