get-html-attributes

Get all HTML attributes as Map<tagName, attributeName[]>, or all elements

Usage no npm install needed!

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

README

get-html-attributes

Get all HTML attributes and the Elements that use them. You can also just get all elements.

Note

The data is fetched from the MDN Web Docs (Elements, Attributes). Because of this when one of the websites changes their HTML (in a certain way), this package will not work propaly anymore. In this case the package will be updated as soon as possible.

Exports

import getAttributes from "get-html-attributes";

or

import { getElements } from "get-html-attributes";

Usage

//The argument is optional
const attributes = await getAttributes({
    deprecatedElements: false,
    deprecatedAttributes: false,
    noExperimentalAttributes: false,
});

const elements = await getElements(); // -> [a, abbr, ...]

const globalAttrs = attributes.get("@global"); // -> [accesskey, contenteditable, ...]
const attrsOfForm = attributes.get("form"); // -> [action, target, ...]