Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 1, 2021
1 parent ebd172e commit 4cdcd16
Showing 1 changed file with 88 additions and 28 deletions.
116 changes: 88 additions & 28 deletions readme.md
Expand Up @@ -6,25 +6,61 @@
[![Size][size-badge]][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.
## Contents

## Install
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`htmlElementAttributes`](#htmlelementattributes)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)

## What is this?

This is a map of tag names to lists of allowed attributes.
Global attributes are stored at the special tag name `*`.
All attributes from HTML 4 and the current living HTML spec are included.

> 👉 **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.
## When should I use this?

This package is ESM only: Node 12+ is needed to use it and it must be `import`ed
instead of `require`d.
You can use this to figure out if certain attributes are allowed on certain
HTML elements.

[npm][]:
## Install

This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:

```sh
npm install html-element-attributes
```

In Deno with [Skypack][]:

```js
import {htmlElementAttributes} from 'https://cdn.skypack.dev/html-element-attributes@3?dts'
```

In browsers with [Skypack][]:

```html
<script type="module">
import {htmlElementAttributes} from 'https://cdn.skypack.dev/html-element-attributes@3?min'
</script>
```

## Use

```js
Expand Down Expand Up @@ -58,28 +94,44 @@ There is no default export.

### `htmlElementAttributes`

`Object.<string, string[]>` — Map of lowercase tag names to an array of
lowercase attribute names.
Map of lowercase HTML elements to allowed attributes
(`Record<string, Array<string>>`).

## Types

This package is fully typed with [TypeScript][].

## Compatibility

The object contains one special key: `'*'`, which contains global
attributes that apply to all HTML elements.
This package is at least compatible with all maintained versions of Node.js.
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
It also works in Deno and modern browsers.

## Security

This package is safe.

## Related

* [`web-namespaces`](https://github.com/wooorm/web-namespaces)
— List of web namespaces
* [`html-tag-names`](https://github.com/wooorm/html-tag-names)
— List of HTML tags
* [`mathml-tag-names`](https://github.com/wooorm/mathml-tag-names)
— List of MathML tags
* [`svg-tag-names`](https://github.com/wooorm/svg-tag-names)
— List of SVG tags
* [`html-void-elements`](https://github.com/wooorm/html-void-elements)
— List of void HTML tag-names
* [`svg-element-attributes`](https://github.com/wooorm/svg-element-attributes)
— Map of SVG elements to allowed attributes
* [`aria-attributes`](https://github.com/wooorm/aria-attributes)
— List of ARIA attributes
* [`wooorm/web-namespaces`](https://github.com/wooorm/web-namespaces)
— list of web namespaces
* [`wooorm/html-tag-names`](https://github.com/wooorm/html-tag-names)
— list of HTML tag names
* [`wooorm/mathml-tag-names`](https://github.com/wooorm/mathml-tag-names)
— list of MathML tag names
* [`wooorm/svg-tag-names`](https://github.com/wooorm/svg-tag-names)
— list of SVG tag names
* [`wooorm/html-void-elements`](https://github.com/wooorm/html-void-elements)
— list of void HTML tag names
* [`wooorm/svg-element-attributes`](https://github.com/wooorm/svg-element-attributes)
— map of SVG elements to attributes
* [`wooorm/aria-attributes`](https://github.com/wooorm/aria-attributes)
— list of ARIA attributes

## Contribute

Yes please!
See [How to Contribute to Open Source][contribute].

## License

Expand All @@ -105,6 +157,14 @@ attributes that apply to all HTML elements.

[npm]: https://docs.npmjs.com/cli/install

[skypack]: https://www.skypack.dev

[license]: license

[author]: https://wooorm.com

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[typescript]: https://www.typescriptlang.org

[contribute]: https://opensource.guide/how-to-contribute/

0 comments on commit 4cdcd16

Please sign in to comment.