Socket
Socket
Sign inDemoInstall

html-element-attributes

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    html-element-attributes

Map of HTML elements to allowed attributes


Version published
Maintainers
1
Install size
14.1 kB
Created

Readme

Source

html-element-attributes

Build Coverage Downloads Size

Map of HTML elements to allowed attributes.

Contents

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. In Node.js (version 14.14+, 16.0+), install with npm:

npm install html-element-attributes

In Deno with esm.sh:

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

In browsers with esm.sh:

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

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 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.

Contribute

Yes please! See How to Contribute to Open Source.

License

MIT © Titus Wormer

Keywords

FAQs

Last updated on 03 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc