├── .editorconfig ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .npmrc ├── .prettierignore ├── build.js ├── funding.yml ├── index.js ├── license ├── package.json ├── readme.md ├── test.js └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: main 2 | on: 3 | - pull_request 4 | - push 5 | jobs: 6 | main: 7 | name: ${{matrix.node}} 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: actions/setup-node@v3 12 | with: 13 | node-version: ${{matrix.node}} 14 | - run: npm install 15 | - run: npm test 16 | - uses: codecov/codecov-action@v1 17 | strategy: 18 | matrix: 19 | node: 20 | - lts/hydrogen 21 | - node 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | node_modules/ 3 | *.d.ts 4 | *.log 5 | .DS_Store 6 | yarn.lock 7 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | *.md 3 | -------------------------------------------------------------------------------- /build.js: -------------------------------------------------------------------------------- 1 | import fs from 'node:fs/promises' 2 | import fetch from 'node-fetch' 3 | import {fromHtml} from 'hast-util-from-html' 4 | import {selectAll} from 'hast-util-select' 5 | import {toString} from 'hast-util-to-string' 6 | import {htmlTagNames} from './index.js' 7 | 8 | // Crawl W3C. 9 | const responseW3c = await fetch('https://w3c.github.io/elements-of-html/') 10 | const textW3c = await responseW3c.text() 11 | 12 | const nodesW3c = selectAll('[scope="row"] code', fromHtml(textW3c)) 13 | let index = -1 14 | 15 | while (++index < nodesW3c.length) { 16 | const data = toString(nodesW3c[index]) 17 | 18 | if (data && !/\s/.test(data)) { 19 | htmlTagNames.push(data) 20 | } 21 | } 22 | 23 | // Crawl WHATWG. 24 | const responseWhatwg = await fetch( 25 | 'https://html.spec.whatwg.org/multipage/indices.html' 26 | ) 27 | const textWhatwg = await responseWhatwg.text() 28 | 29 | const nodesWhatwg = selectAll('tbody th code', fromHtml(textWhatwg)) 30 | index = -1 31 | 32 | while (++index < nodesWhatwg.length) { 33 | const node = nodesWhatwg[index] 34 | const id = String((node.properties || {}).id || '') 35 | const data = toString(node) 36 | 37 | if (id && id.slice(0, 'elements-3:'.length) === 'elements-3:') { 38 | htmlTagNames.push(data) 39 | } 40 | } 41 | 42 | const list = [...new Set(htmlTagNames)].sort() 43 | 44 | await fs.writeFile( 45 | 'index.js', 46 | [ 47 | '/**', 48 | ' * List of known HTML tag names.', 49 | ' *', 50 | ' * @type {Array}', 51 | ' */', 52 | 'export const htmlTagNames = ' + JSON.stringify(list, null, 2), 53 | '' 54 | ].join('\n') 55 | ) 56 | -------------------------------------------------------------------------------- /funding.yml: -------------------------------------------------------------------------------- 1 | github: wooorm 2 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * List of known HTML tag names. 3 | * 4 | * @type {Array} 5 | */ 6 | export const htmlTagNames = [ 7 | 'a', 8 | 'abbr', 9 | 'acronym', 10 | 'address', 11 | 'applet', 12 | 'area', 13 | 'article', 14 | 'aside', 15 | 'audio', 16 | 'b', 17 | 'base', 18 | 'basefont', 19 | 'bdi', 20 | 'bdo', 21 | 'bgsound', 22 | 'big', 23 | 'blink', 24 | 'blockquote', 25 | 'body', 26 | 'br', 27 | 'button', 28 | 'canvas', 29 | 'caption', 30 | 'center', 31 | 'cite', 32 | 'code', 33 | 'col', 34 | 'colgroup', 35 | 'command', 36 | 'content', 37 | 'data', 38 | 'datalist', 39 | 'dd', 40 | 'del', 41 | 'details', 42 | 'dfn', 43 | 'dialog', 44 | 'dir', 45 | 'div', 46 | 'dl', 47 | 'dt', 48 | 'element', 49 | 'em', 50 | 'embed', 51 | 'fieldset', 52 | 'figcaption', 53 | 'figure', 54 | 'font', 55 | 'footer', 56 | 'form', 57 | 'frame', 58 | 'frameset', 59 | 'h1', 60 | 'h2', 61 | 'h3', 62 | 'h4', 63 | 'h5', 64 | 'h6', 65 | 'head', 66 | 'header', 67 | 'hgroup', 68 | 'hr', 69 | 'html', 70 | 'i', 71 | 'iframe', 72 | 'image', 73 | 'img', 74 | 'input', 75 | 'ins', 76 | 'isindex', 77 | 'kbd', 78 | 'keygen', 79 | 'label', 80 | 'legend', 81 | 'li', 82 | 'link', 83 | 'listing', 84 | 'main', 85 | 'map', 86 | 'mark', 87 | 'marquee', 88 | 'math', 89 | 'menu', 90 | 'menuitem', 91 | 'meta', 92 | 'meter', 93 | 'multicol', 94 | 'nav', 95 | 'nextid', 96 | 'nobr', 97 | 'noembed', 98 | 'noframes', 99 | 'noscript', 100 | 'object', 101 | 'ol', 102 | 'optgroup', 103 | 'option', 104 | 'output', 105 | 'p', 106 | 'param', 107 | 'picture', 108 | 'plaintext', 109 | 'pre', 110 | 'progress', 111 | 'q', 112 | 'rb', 113 | 'rbc', 114 | 'rp', 115 | 'rt', 116 | 'rtc', 117 | 'ruby', 118 | 's', 119 | 'samp', 120 | 'script', 121 | 'search', 122 | 'section', 123 | 'select', 124 | 'shadow', 125 | 'slot', 126 | 'small', 127 | 'source', 128 | 'spacer', 129 | 'span', 130 | 'strike', 131 | 'strong', 132 | 'style', 133 | 'sub', 134 | 'summary', 135 | 'sup', 136 | 'svg', 137 | 'table', 138 | 'tbody', 139 | 'td', 140 | 'template', 141 | 'textarea', 142 | 'tfoot', 143 | 'th', 144 | 'thead', 145 | 'time', 146 | 'title', 147 | 'tr', 148 | 'track', 149 | 'tt', 150 | 'u', 151 | 'ul', 152 | 'var', 153 | 'video', 154 | 'wbr', 155 | 'xmp' 156 | ] 157 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2016 Titus Wormer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | 'Software'), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "html-tag-names", 3 | "version": "2.1.0", 4 | "description": "List of known HTML tag names", 5 | "license": "MIT", 6 | "keywords": [ 7 | "html", 8 | "tag", 9 | "name", 10 | "element", 11 | "tagname", 12 | "w3c", 13 | "whatwg" 14 | ], 15 | "repository": "wooorm/html-tag-names", 16 | "bugs": "https://github.com/wooorm/html-tag-names/issues", 17 | "funding": { 18 | "type": "github", 19 | "url": "https://github.com/sponsors/wooorm" 20 | }, 21 | "author": "Titus Wormer (https://wooorm.com)", 22 | "contributors": [ 23 | "Titus Wormer (https://wooorm.com)", 24 | "Valerio Coltrè " 25 | ], 26 | "sideEffects": false, 27 | "type": "module", 28 | "main": "index.js", 29 | "types": "index.d.ts", 30 | "files": [ 31 | "index.d.ts", 32 | "index.js" 33 | ], 34 | "devDependencies": { 35 | "@types/node": "^20.0.0", 36 | "c8": "^8.0.0", 37 | "hast-util-from-html": "^2.0.0", 38 | "hast-util-select": "^6.0.0", 39 | "hast-util-to-string": "^3.0.0", 40 | "node-fetch": "^3.0.0", 41 | "prettier": "^3.0.0", 42 | "remark-cli": "^11.0.0", 43 | "remark-preset-wooorm": "^9.0.0", 44 | "type-coverage": "^2.0.0", 45 | "typescript": "^5.0.0", 46 | "xo": "^0.56.0" 47 | }, 48 | "scripts": { 49 | "prepack": "npm run build && npm run format", 50 | "generate": "node --conditions development build.js", 51 | "build": "tsc --build --clean && tsc --build && type-coverage", 52 | "format": "remark . -qfo && prettier . -w --log-level warn && xo --fix", 53 | "test-api": "node --conditions development test.js", 54 | "test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api", 55 | "test": "npm run generate && npm run build && npm run format && npm run test-coverage" 56 | }, 57 | "prettier": { 58 | "tabWidth": 2, 59 | "useTabs": false, 60 | "singleQuote": true, 61 | "bracketSpacing": false, 62 | "semi": false, 63 | "trailingComma": "none" 64 | }, 65 | "xo": { 66 | "prettier": true 67 | }, 68 | "remarkConfig": { 69 | "plugins": [ 70 | "preset-wooorm" 71 | ] 72 | }, 73 | "typeCoverage": { 74 | "atLeast": 100, 75 | "detail": true, 76 | "strict": true, 77 | "ignoreCatch": true 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # html-tag-names 2 | 3 | [![Build][build-badge]][build] 4 | [![Coverage][coverage-badge]][coverage] 5 | [![Downloads][downloads-badge]][downloads] 6 | [![Size][size-badge]][size] 7 | 8 | List of known HTML tag names. 9 | 10 | ## Contents 11 | 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 | * [`htmlTagNames`](#htmltagnames) 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 list of HTML tag names. 28 | It includes ancient (for example, `nextid` and `basefont`) and modern (for 29 | example, `search` and `shadow`) names from the HTML living standard. 30 | The repo includes scripts to regenerate the data from the specs. 31 | 32 | ## When should I use this? 33 | 34 | You can use this package when you need to know what tag names are allowed in 35 | any version of HTML. 36 | 37 | ## Install 38 | 39 | This package is [ESM only][esm]. 40 | In Node.js (version 14.14+, 16.0+), install with [npm][]: 41 | 42 | ```sh 43 | npm install html-tag-names 44 | ``` 45 | 46 | In Deno with [`esm.sh`][esmsh]: 47 | 48 | ```js 49 | import {htmlTagNames} from 'https://esm.sh/html-tag-names@2' 50 | ``` 51 | 52 | In browsers with [`esm.sh`][esmsh]: 53 | 54 | ```html 55 | 58 | ``` 59 | 60 | ## Use 61 | 62 | ```js 63 | import {htmlTagNames} from 'html-tag-names' 64 | 65 | console.log(htmlTagNames.length) // => 148 66 | 67 | console.log(htmlTagNames.slice(0, 20)) 68 | ``` 69 | 70 | Yields: 71 | 72 | ```js 73 | [ 74 | 'a', 75 | 'abbr', 76 | 'acronym', 77 | 'address', 78 | 'applet', 79 | 'area', 80 | 'article', 81 | 'aside', 82 | 'audio', 83 | 'b', 84 | 'base', 85 | 'basefont', 86 | 'bdi', 87 | 'bdo', 88 | 'bgsound', 89 | 'big', 90 | 'blink', 91 | 'blockquote', 92 | 'body', 93 | 'br' 94 | ] 95 | ``` 96 | 97 | ## API 98 | 99 | This package exports the identifier `htmlTagNames`. 100 | There is no default export. 101 | 102 | ### `htmlTagNames` 103 | 104 | List of known (lowercase) HTML tag names (`Array`). 105 | 106 | ## Types 107 | 108 | This package is fully typed with [TypeScript][]. 109 | It exports no additional types. 110 | 111 | ## Compatibility 112 | 113 | This package is at least compatible with all maintained versions of Node.js. 114 | As of now, that is Node.js 14.14+ and 16.0+. 115 | It also works in Deno and modern browsers. 116 | 117 | ## Security 118 | 119 | This package is safe. 120 | 121 | ## Related 122 | 123 | * [`wooorm/mathml-tag-names`](https://github.com/wooorm/mathml-tag-names) 124 | — list of MathML tag names 125 | * [`wooorm/svg-tag-names`](https://github.com/wooorm/svg-tag-names) 126 | — list of SVG tag names 127 | * [`jgierer12/react-tag-names`](https://github.com/jgierer12/react-tag-names) 128 | — list of React’s HTML and SVG tag names 129 | * [`wooorm/svg-element-attributes`](https://github.com/wooorm/svg-element-attributes) 130 | — map of SVG elements to attributes 131 | * [`wooorm/html-element-attributes`](https://github.com/wooorm/html-element-attributes) 132 | — map of HTML elements to attributes 133 | * [`wooorm/aria-attributes`](https://github.com/wooorm/aria-attributes) 134 | — list of ARIA attributes 135 | 136 | ## Contribute 137 | 138 | Yes please! 139 | See [How to Contribute to Open Source][contribute]. 140 | 141 | ## License 142 | 143 | [MIT][license] © [Titus Wormer][author] 144 | 145 | 146 | 147 | [build-badge]: https://github.com/wooorm/html-tag-names/workflows/main/badge.svg 148 | 149 | [build]: https://github.com/wooorm/html-tag-names/actions 150 | 151 | [coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/html-tag-names.svg 152 | 153 | [coverage]: https://codecov.io/github/wooorm/html-tag-names 154 | 155 | [downloads-badge]: https://img.shields.io/npm/dm/html-tag-names.svg 156 | 157 | [downloads]: https://www.npmjs.com/package/html-tag-names 158 | 159 | [size-badge]: https://img.shields.io/bundlephobia/minzip/html-tag-names.svg 160 | 161 | [size]: https://bundlephobia.com/result?p=html-tag-names 162 | 163 | [npm]: https://docs.npmjs.com/cli/install 164 | 165 | [esmsh]: https://esm.sh 166 | 167 | [license]: license 168 | 169 | [author]: https://wooorm.com 170 | 171 | [esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c 172 | 173 | [typescript]: https://www.typescriptlang.org 174 | 175 | [contribute]: https://opensource.guide/how-to-contribute/ 176 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import assert from 'node:assert/strict' 2 | import test from 'node:test' 3 | import {htmlTagNames} from './index.js' 4 | 5 | test('htmlTagNames', function () { 6 | let index = -1 7 | 8 | assert.ok(Array.isArray(htmlTagNames), 'should be an `array`') 9 | 10 | while (++index < htmlTagNames.length) { 11 | assert.equal( 12 | typeof htmlTagNames[index], 13 | 'string', 14 | '`' + htmlTagNames[index] + '` should be a string' 15 | ) 16 | } 17 | }) 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["**/**.js"], 3 | "exclude": ["coverage", "node_modules"], 4 | "compilerOptions": { 5 | "checkJs": true, 6 | "declaration": true, 7 | "emitDeclarationOnly": true, 8 | "exactOptionalPropertyTypes": true, 9 | "forceConsistentCasingInFileNames": true, 10 | "lib": ["es2020"], 11 | "module": "node16", 12 | "newLine": "lf", 13 | "skipLibCheck": true, 14 | "strict": true, 15 | "target": "es2020" 16 | } 17 | } 18 | --------------------------------------------------------------------------------