Skip to Content
  • Website
Codsen
  • Home
  • Open Source
  • Articles
  • About

prevOpen Source→is-char-suitable-for-html-attr-namenext

is-char-suitable-for-html-attr-name4.2.1

Is given character suitable to be in an HTML attribute’s name?

Downloads per monthChangelogMIT Licenselibera manifesto
  • the top
  • Installation
  • Quick Take
  • Examples
  • PURPOSE
  • API — ISATTRNAMECH…
  • ALSO
  • Changelog

Installation

Quick Take

Examples

  • Only the first character is checked
  • Characters rejected in attribute names
  • Characters allowed in attribute names

Purpose

It’s a function which validates strings (first character of it), is it suitable to be in an HTML attribute’s name. See the official specopens in a new tab for HTML attribute names.

API — isAttrNameChar()

The main function isAttrNameChar() is imported like this:

It’s a function which takes one input argument:

Input argumentTypeObligatoryDescription
str
Type: String
Obligatory: yes
strStringyesThe character to evaluate.

The function always returns a boolean and never throws errors.

In case of non-string input or empty string, it just returns false.

If the input string is longer than 1, its first character is used.

Also

If you need a comprehensive list of all possible HTML attribute names, check out html-all-known-attributes.

Changelog

Open Changelog
↑ back to top
prev next

Copyright

All rights reserved © Roy Revelt 2026
All our open source packages are under MIT licenceopens in a new tab

Activities

🐛 See a bug? Raise an issueopens in a new tab
💘 Check out the Indiewebopens in a new tab and Libera manifestoopens in a new tab