GithubHelp home page GithubHelp logo

html-element-attributes's Introduction

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.

Related

Contribute

Yes please! See How to Contribute to Open Source.

License

MIT ยฉ Titus Wormer

html-element-attributes's People

Contributors

fisker avatar greenkeeperio-bot avatar wooorm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

html-element-attributes's Issues

<span> is missing.

This might be because it doesn't have any attributes โ€” is that how this works?

Authoring question

As a language-server author, I'm considering using this library,
however, the types of

 * @type {Record<string, Array<string>>}

are not specific enough.

if the index.js were ts (and generated a js + d.ts) we could as const the attribute lists to get TS-fine-grained attribute suggestions in language servers (wrapping TS, such as what Vue, Svelte, and Ember do).

However, I understand if a repo doesn't want to adopt TS, and we can have a manually maintained .d.ts file, but it would basically be a duplicate of the index.js.

Deprecated attributes?

Is it possible to somehow know which attributes are deprecated? Maybe if not in this list, is there another list with HTML5-only things so I can do cross-referencing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.