Skip to content

Commit 4cdcd16

Browse files
committed
Update docs
1 parent ebd172e commit 4cdcd16

File tree

1 file changed

+88
-28
lines changed

1 file changed

+88
-28
lines changed

readme.md

Lines changed: 88 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,61 @@
66
[![Size][size-badge]][size]
77

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

12-
> **Note**: Includes deprecated attributes.
13-
>
14-
> **Note**: Attributes which were not global in HTML 4 but are in HTML, are only
15-
> included in the list of global attributes.
10+
## Contents
1611

17-
## Install
12+
* [What is this?](#what-is-this)
13+
* [When should I use this?](#when-should-i-use-this)
14+
* [Install](#install)
15+
* [Use](#use)
16+
* [API](#api)
17+
* [`htmlElementAttributes`](#htmlelementattributes)
18+
* [Types](#types)
19+
* [Compatibility](#compatibility)
20+
* [Security](#security)
21+
* [Related](#related)
22+
* [Contribute](#contribute)
23+
* [License](#license)
24+
25+
## What is this?
26+
27+
This is a map of tag names to lists of allowed attributes.
28+
Global attributes are stored at the special tag name `*`.
29+
All attributes from HTML 4 and the current living HTML spec are included.
30+
31+
> 👉 **Note**: Includes deprecated attributes.
32+
33+
> 👉 **Note**: Attributes which were not global in HTML 4 but are in HTML, are
34+
> only included in the list of global attributes.
35+
36+
## When should I use this?
1837

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

22-
[npm][]:
41+
## Install
42+
43+
This package is [ESM only][esm].
44+
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
2345

2446
```sh
2547
npm install html-element-attributes
2648
```
2749

50+
In Deno with [Skypack][]:
51+
52+
```js
53+
import {htmlElementAttributes} from 'https://cdn.skypack.dev/html-element-attributes@3?dts'
54+
```
55+
56+
In browsers with [Skypack][]:
57+
58+
```html
59+
<script type="module">
60+
import {htmlElementAttributes} from 'https://cdn.skypack.dev/html-element-attributes@3?min'
61+
</script>
62+
```
63+
2864
## Use
2965

3066
```js
@@ -58,28 +94,44 @@ There is no default export.
5894

5995
### `htmlElementAttributes`
6096

61-
`Object.<string, string[]>` — Map of lowercase tag names to an array of
62-
lowercase attribute names.
97+
Map of lowercase HTML elements to allowed attributes
98+
(`Record<string, Array<string>>`).
99+
100+
## Types
101+
102+
This package is fully typed with [TypeScript][].
103+
104+
## Compatibility
63105

64-
The object contains one special key: `'*'`, which contains global
65-
attributes that apply to all HTML elements.
106+
This package is at least compatible with all maintained versions of Node.js.
107+
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
108+
It also works in Deno and modern browsers.
109+
110+
## Security
111+
112+
This package is safe.
66113

67114
## Related
68115

69-
* [`web-namespaces`](https://github.com/wooorm/web-namespaces)
70-
— List of web namespaces
71-
* [`html-tag-names`](https://github.com/wooorm/html-tag-names)
72-
— List of HTML tags
73-
* [`mathml-tag-names`](https://github.com/wooorm/mathml-tag-names)
74-
— List of MathML tags
75-
* [`svg-tag-names`](https://github.com/wooorm/svg-tag-names)
76-
— List of SVG tags
77-
* [`html-void-elements`](https://github.com/wooorm/html-void-elements)
78-
— List of void HTML tag-names
79-
* [`svg-element-attributes`](https://github.com/wooorm/svg-element-attributes)
80-
— Map of SVG elements to allowed attributes
81-
* [`aria-attributes`](https://github.com/wooorm/aria-attributes)
82-
— List of ARIA attributes
116+
* [`wooorm/web-namespaces`](https://github.com/wooorm/web-namespaces)
117+
— list of web namespaces
118+
* [`wooorm/html-tag-names`](https://github.com/wooorm/html-tag-names)
119+
— list of HTML tag names
120+
* [`wooorm/mathml-tag-names`](https://github.com/wooorm/mathml-tag-names)
121+
— list of MathML tag names
122+
* [`wooorm/svg-tag-names`](https://github.com/wooorm/svg-tag-names)
123+
— list of SVG tag names
124+
* [`wooorm/html-void-elements`](https://github.com/wooorm/html-void-elements)
125+
— list of void HTML tag names
126+
* [`wooorm/svg-element-attributes`](https://github.com/wooorm/svg-element-attributes)
127+
— map of SVG elements to attributes
128+
* [`wooorm/aria-attributes`](https://github.com/wooorm/aria-attributes)
129+
— list of ARIA attributes
130+
131+
## Contribute
132+
133+
Yes please!
134+
See [How to Contribute to Open Source][contribute].
83135

84136
## License
85137

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

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

160+
[skypack]: https://www.skypack.dev
161+
108162
[license]: license
109163

110164
[author]: https://wooorm.com
165+
166+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
167+
168+
[typescript]: https://www.typescriptlang.org
169+
170+
[contribute]: https://opensource.guide/how-to-contribute/

0 commit comments

Comments
 (0)