html-element-attributes

Map of HTML elements to allowed attributes

Usage no npm install needed!

<script type="module">
  import htmlElementAttributes from 'https://cdn.skypack.dev/html-element-attributes';
</script>

README

html-element-attributes

Build Coverage Downloads Size

Map of HTML elements to allowed attributes. Also contains global attributes under '*'. Includes attributes from HTML 4 and HTML (the WHATWG living standard).

Note: Includes deprecated attributes.

Note: Attributes which were not global in HTML 4 but are in HTML, are only included in the list of global attributes.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install html-element-attributes

Use

import {htmlElementAttributes} from 'html-element-attributes'

console.log(htmlElementAttributes['*'])
console.log(htmlElementAttributes.ol)

Yields:

[
  'accesskey',
  'autocapitalize',
  'autofocus',
  'class',
  // …
  'style',
  'tabindex',
  'title',
  'translate'
]
['compact', 'reversed', 'start', 'type']

API

This package exports the following identifiers: htmlElementAttributes. There is no default export.

htmlElementAttributes

Object.<string, string[]> — Map of lowercase tag names to an array of lowercase attribute names.

The object contains one special key: '*', which contains global attributes that apply to all HTML elements.

Related

License

MIT © Titus Wormer