# doctype

> Information for HTML doctypes

Latest version **3.0.1** (published 2021-10-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install doctype
pnpm add doctype
yarn add doctype
bun add doctype
```

## Health

**Score 30/100 (F)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2021-10-27 |
| First published | 2015-10-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Titus Wormer |
| Maintainers | wooorm |
| Keywords | xhtml, html, svg, mathml, doctype, doctypes, info, information |

## Links

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

## 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.0.1 (latest) — 2021-10-27
- 3.0.0 — 2021-03-08
- 2.0.4 — 2020-01-24
- 2.0.3 — 2019-05-11
- 2.0.2 — 2018-04-28
- 2.0.1 — 2017-07-20
- 2.0.0 — 2016-08-14
- 1.1.0 — 2015-10-10
- 1.0.1 — 2015-10-09
- 1.0.0 — 2015-10-09

## README

# doctype

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

Info on HTML / XHTML / MathML / SVG doctypes.

## Contents

*   [Install](#install)
*   [Use](#use)
*   [API](#api)
    *   [`doctype(name)`](#doctypename)
    *   [`doctypes`](#doctypes)
*   [Types](#types)
*   [Compatibility](#compatibility)
*   [Security](#security)
*   [Related](#related)
*   [Contribute](#contribute)
*   [License](#license)

## Install

This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:

```sh
npm install doctype
```

In Deno with [Skypack][]:

```js
import {doctype} from 'https://cdn.skypack.dev/doctype@3?dts'
```

In browsers with [Skypack][]:

```html
<script type="module">
  import {doctype} from 'https://cdn.skypack.dev/doctype@3?min'
</script>
```

## Use

```js
import {doctype} from 'doctype'

console.log(doctype(5)) // => 'html'

console.log(doctype(4.01))
console.log(doctype('4.01t'))
console.log(doctype('4.01 Transitional'))
console.log(doctype('HTML 4.01 Transitional'))
// => 'HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"'

console.log(doctype('svg'))
// => 'svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"'
```

## API

This package exports the following identifiers: [`doctype`](#doctypename) and
[`doctypes`](#doctypes).
There is no default export.

### `doctype(name)`

Get a doctype from a fuzzy doctype name.

###### Parameters

*   `name` (`string`, `number`)
    — fuzzy doctype name which is stripped from white space, casing, fractional
    part of version, `'HTML'` or `'XHTML'` prefix, and whose suffixes are
    normalized (`Transitional` to `t`)

###### Returns

`string?` — doctype string when found.

### `doctypes`

`Object` mapping doctype names to doctype strings.

```js
{
  'HTML 5': 'html',
  'HTML 4.01 Strict': 'HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"',
  // …
}
```

## Types

This package is fully typed with [TypeScript][].

## Compatibility

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

## Security

This package is safe.

## Related

*   [`wooorm/html-tag-names`](https://github.com/wooorm/html-tag-names)
    — list of HTML tag names
*   [`wooorm/html-element-attributes`](https://github.com/wooorm/html-element-attributes)
    — map of HTML attributes
*   [`wooorm/html-void-elements`](https://github.com/wooorm/html-void-elements)
    — list of void HTML tag-names
*   [`wooorm/property-information`](https://github.com/wooorm/property-information)
    — info on HTML, SVG, etc properties
*   [`wooorm/web-namespaces`](https://github.com/wooorm/web-namespaces)
    — map of web namespaces

## Contribute

Yes please!
See [How to Contribute to Open Source][contribute].

## License

[MIT][license] © [Titus Wormer][author]

<!-- Definitions -->

[build-badge]: https://github.com/wooorm/doctype/workflows/main/badge.svg

[build]: https://github.com/wooorm/doctype/actions

[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/doctype.svg

[coverage]: https://codecov.io/github/wooorm/doctype

[downloads-badge]: https://img.shields.io/npm/dm/doctype.svg

[downloads]: https://www.npmjs.com/package/doctype

[size-badge]: https://img.shields.io/bundlephobia/minzip/doctype.svg

[size]: https://bundlephobia.com/result?p=doctype

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

[skypack]: https://www.skypack.dev

[license]: license

[author]: https://wooorm.com

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

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

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

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