# html-element-attributes

> Map of HTML elements to allowed attributes

Latest version **3.5.0** (published 2025-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-element-attributes
pnpm add html-element-attributes
yarn add html-element-attributes
bun add html-element-attributes
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.5.0 |
| Published | 2025-07-28 |
| First published | 2016-03-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 64 |
| Author | Titus Wormer |
| Maintainers | wooorm |
| Keywords | attribute, element, html, name, property, tag, w3c, whatwg |

## Links

- npm: https://www.npmjs.com/package/html-element-attributes
- Repository: https://github.com/wooorm/html-element-attributes
- Homepage: https://github.com/wooorm/html-element-attributes#readme
- Issues: https://github.com/wooorm/html-element-attributes/issues
- Funding: https://github.com/sponsors/wooorm
- npm.io page: https://npm.io/package/html-element-attributes

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 3.5.0 (latest) — 2025-07-28
- 3.4.0 — 2024-04-03
- 3.3.0 — 2023-11-01
- 3.2.0 — 2023-04-07
- 3.1.0 — 2021-11-01
- 3.0.0 — 2021-03-26
- 2.3.0 — 2020-10-13
- 2.2.1 — 2020-01-24
- 2.2.0 — 2019-10-15
- 2.1.0 — 2019-05-14
- 2.0.0 — 2018-06-25
- 1.3.1 — 2018-04-14
- 1.3.0 — 2017-06-25
- 1.2.0 — 2017-04-08
- 1.1.0 — 2016-11-07
- … 1 more at https://npm.io/package/html-element-attributes/versions

## README

# html-element-attributes

[![Build][badge-build-image]][badge-build-url]
[![Coverage][badge-coverage-image]][badge-coverage-url]
[![Downloads][badge-downloads-image]][badge-downloads-url]
[![Size][badge-size-image]][badge-size-url]

Map of HTML elements to allowed attributes.

## Contents

* [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?

You can use this to figure out if certain attributes are allowed on certain
HTML elements.

## Install

This package is [ESM only][github-gist-esm].
In Node.js (version 14.14+, 16.0+), install with [npm][npmjs-install]:

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

In Deno with [`esm.sh`][esmsh]:

```js
import {htmlElementAttributes} from 'https://esm.sh/html-element-attributes@3'
```

In browsers with [`esm.sh`][esmsh]:

```html
<script type="module">
  import {htmlElementAttributes} from 'https://esm.sh/html-element-attributes@3?bundle'
</script>
```

## Use

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

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

Yields:

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

## API

This package exports the identifier `htmlElementAttributes`.
There is no default export.

### `htmlElementAttributes`

Map of lowercase HTML elements to allowed attributes
(`Record<string, Array<string>>`).

## Types

This package is fully typed with [TypeScript][].
It exports no additional types.

## Compatibility

This package is at least compatible with all maintained versions of Node.js.
As of now, that is Node.js 14.14+ and 16.0+.
It also works in Deno and modern browsers.

## Security

This package is safe.

## Related

* [`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][opensource-guide].

## License

[MIT][file-license] © [Titus Wormer][wooorm]

<!-- Definition -->

[badge-build-image]: https://github.com/wooorm/html-element-attributes/workflows/main/badge.svg

[badge-build-url]: https://github.com/wooorm/html-element-attributes/actions

[badge-coverage-image]: https://img.shields.io/codecov/c/github/wooorm/html-element-attributes.svg

[badge-coverage-url]: https://codecov.io/github/wooorm/html-element-attributes

[badge-downloads-image]: https://img.shields.io/npm/dm/html-element-attributes.svg

[badge-downloads-url]: https://www.npmjs.com/package/html-element-attributes

[badge-size-image]: https://img.shields.io/bundlejs/size/html-element-attributes

[badge-size-url]: https://bundlejs.com/?q=html-element-attributes

[esmsh]: https://esm.sh

[file-license]: license

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

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

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

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

[wooorm]: https://wooorm.com

---
_Source: https://npm.io/package/html-element-attributes · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
