mrkeyoor.com_
Wed 23 Sept 00:34 UTC
npmWeb Frontendupdated 22 Sept 2026

sanitize.css review

sanitize.css 13.0.0 is a global CSS baseline that combines normalize.css-style browser fixes with choices such as border-box sizing, non-repeating backgrounds, zero body margin, 1.5 line height, aggressive word breaking, collapsed table borders, and vertical textarea resizing. Optional stylesheets cover forms, assets, typography, reduced motion, and font aliases. The current npm release is still from 2021 even though repository work continued in 2026. Despite its name, this package does not inspect untrusted HTML or CSS and provides no security sanitization.

Verdict

Our sanitize.css 13.0.0 install took 0.6 seconds and had 0 dependencies or audit findings, but JavaScript `require()` and `import` both failed because the package is CSS. Use it once as a reviewed global baseline; do not install it as a security sanitizer or alongside another reset without a cascade audit.

We installed it

Lab card: what happened when we installed sanitize.cssScreenshot of sanitize.css documentation
Install✓ · 0.6s1 package on disk · 1 MB
ImportESM import fails · require() fails · CommonJS package
Browser0.1 KBgzipped (0.1 KB minified), bundled with esbuild
Typesno TypeScript types found
Known vulns00 critical · 0 high · 0 moderate · 0 low (npm audit)

Answers from our run

Does sanitize.css install cleanly?

Yes. In a fresh container with an empty cache, npm install sanitize.css finished in 0.6s, leaving 1 package and 1 MB on disk. npm audit reported no known vulnerabilities.

How much does sanitize.css add to a browser bundle?

0.1 KB gzipped (0.1 KB minified) when the whole package is bundled for the browser with esbuild. Importing only part of it is usually smaller.

Does sanitize.css work with both ESM and CommonJS?

Neither plain import nor require succeeded in our sandbox, so it needs a bundler or extra setup.

Does sanitize.css include TypeScript types?

No type declarations were found in our install, so TypeScript users need their own declarations.

sanitize.css or normalize.css: which should you use?

normalize.css: Use it for browser corrections with fewer opinionated visual defaults. Our sanitize.css 13.0.0 install took 0.6 seconds and had 0 dependencies or audit findings, but JavaScript require() and import both failed because the package is CSS.

When should you not use sanitize.css?

You need XSS or CSS sanitization; this is a static stylesheet and parses no user input.

API stability3/5The package's interface is a set of global CSS files rather than functions, and version 13.0.0 keeps root, forms, assets, typography, motion, and font modules independently importable. Global selectors make every declaration part of the effective API. Repository changes after the 2021 npm release also mean the website and main branch may describe behavior that is absent from the installed artifact.
Docs4/5The README shows npm, link, CSS import, and JavaScript bundler use; names every optional stylesheet; lists supported browsers; and explains individual normalization and opinion rules beside their CSS. It does not make the npm-versus-main version gap prominent, and its Internet Explorer 9 claim conflicts with broad use of `:where()`, which that browser ignores.
Maintenance2/5npm published 13.0.0 on 2021-09-14, while GitHub reports the repository's last push on 2026-03-26 and currently lists 22 open issues and pull requests. The repository is active and not archived, but fixes on main have not produced a newer npm artifact. Consumers therefore need to distinguish current source documentation from the five-year-old published version.
Ecosystem4/5npm recorded 3,144,131 downloads for the week ending 2026-08-24, and the package sits in the familiar reset and normalize part of frontend tooling. Plain CSS works with any framework or static site once the build understands CSS imports. That portability also creates collision risk because component libraries, utility frameworks, and browser resets often define the same global elements.

Use it if

  • A new site wants normalize.css fixes plus the package's documented global defaults.
  • Zero-specificity `:where()` rules fit the project's cascade strategy.
  • Forms, assets, typography, and reduced-motion rules will be reviewed and imported separately.
  • The team can run visual regression checks across native controls, content, navigation, and print.
Skip it if

Setup reality

Our sanitize.css 13.0.0 install completed in 0.6 seconds and left 1 package using 1 MB on disk. It is 60 KB unpacked, has 0 direct dependencies and 0 peers, and returned 0 findings from npm audit. There is no JavaScript setup, native build, credential, or runtime configuration.

This is CSS, not an executable CommonJS module. Both Node 22 require() and ESM import failed in our sandbox, so import the stylesheet through a bundler with CSS handling or link it from HTML. The package has no TypeScript declarations because it exposes stylesheets rather than typed functions.

The root file does not automatically include forms.css, assets.css, typography.css, reduce-motion.css, system-ui.css, or ui-monospace.css. Add only reviewed modules and pin any CDN URL to version 13.0.0. Import order matters when zero-specificity rules tie, and the universal box-sizing and background rules do not use :where().

The reduced-motion file applies timing changes with !important across elements and pseudo-elements, which can affect code waiting for transition or animation events. Forms alter control typography, borders, padding, backgrounds, and select arrows. Our esbuild import measured only 0.1 KB because JavaScript bundling does not represent the stylesheet payload; assess the actual CSS through your production CSS pipeline and screenshot the affected pages.

Patterns

Load the core foundation from JavaScript import-core-styles

import 'sanitize.css';
import './app.css';

Import sanitize.css before application styles so equal-specificity rules in app.css come later. Your bundler must be configured to process CSS imports.

Load the foundation from global CSS import-from-css

@import 'sanitize.css';

/* Project tokens and components follow. */
@import './tokens.css';
@import './components.css';

Package import resolution depends on the CSS build tool. The README's webpack tilde form is unnecessary in many current toolchains.

Use a version-pinned browser stylesheet load-pinned-cdn

<link rel="stylesheet" href="https://unpkg.com/sanitize.css@13.0.0/sanitize.css">

A pinned URL prevents an upstream release from changing every page unexpectedly. A CDN remains an availability and policy dependency.

Opt into the separate forms baseline normalize-form-controls

import 'sanitize.css';
import 'sanitize.css/forms.css';

forms.css changes borders, padding, backgrounds, inherited fonts, range and color inputs, and select appearance. It is not included by the root import.

Keep common assets within their container constrain-page-assets

import 'sanitize.css';
import 'sanitize.css/assets.css';

In npm 13.0.0 this affects iframe, img, input, video, select, and textarea. Newer main-branch documentation may describe a different selector list.

Apply the optional system font stacks use-system-typography

import 'sanitize.css';
import 'sanitize.css/typography.css';

typography.css uses ordinary html, code, kbd, samp, and pre selectors rather than zero-specificity :where(), so overrides need normal cascade planning.

Load the reduced-motion policy respect-reduced-motion

import 'sanitize.css/reduce-motion.css';

Version 13 applies !important duration and delay overrides globally. Test components that rely on animation or transition completion events before enabling it.

Put sanitize.css in a low-priority layer place-in-cascade-layer

@layer reset, tokens, components, utilities;

@import 'sanitize.css' layer(reset);
@import './tokens.css' layer(tokens);
@import './components.css' layer(components);

Layer ordering can make the baseline predictable even when selector specificity differs. Verify that your target browsers and CSS processor preserve import layers.

Replace an opinionated root default override-root-defaults

:root {
  line-height: 1.4;
  overflow-wrap: normal;
  tab-size: 2;
}

The core root declarations use :where(:root), which has zero specificity, so a later ordinary :root rule overrides them cleanly.

Restore list styling inside navigation restore-navigation-markers

nav ul.docs-tree {
  list-style: disc;
  padding-inline-start: 1.5rem;
}

nav ul.docs-tree > li::before {
  content: none;
  float: none;
}

The core sheet removes nav list markers and inserts a zero-width pseudo-element for Safari semantics. Override both when a navigation tree needs visible bullets or flex-safe children.

Opt a component back into repeating backgrounds restore-repeating-background

.checkerboard {
  background-image: var(--checker-pattern);
  background-repeat: repeat;
}

The universal core rule sets background-repeat: no-repeat on every element and pseudo-element, so repeating patterns must opt back in.

Inspect the exact CSS shipped by npm audit-installed-version

npm ls sanitize.css
node -e "console.log(require.resolve('sanitize.css/sanitize.css'))"

The website follows repository main, while npm 13.0.0 predates 2026 source changes. Review the resolved file when a documented rule seems absent.

Alternatives

PackageRegistryPick it when
normalize.cssnpmUse it for browser corrections with fewer opinionated visual defaults.
modern-normalizenpmUse it for a compact baseline aimed at current browsers.
@csstools/normalize.cssnpmUse the CSSTools-maintained normalize line when normalization is enough.

More web frontend guides

postcss · react · react-dom · tailwindcss · htmlparser2 · tailwind-merge · the whole shelf →

How this guide is made: grounded in the library's documentation, release notes, changelog, and issue history, on a fixed rubric — not a hands-on install of every release. The 50 most-downloaded entries are additionally install-verified in clean containers. Corrections: contact the desk.