sanitize.css is a CSS library that provides consistent, cross-browser default styling of HTML elements alongside useful defaults.
It is developed alongside normalize.css, which means every normalization is included, and every normalization and opinion are clearly marked and documented.
<link href="https://unpkg.com/sanitize.css" rel="stylesheet" />
A separate stylesheet that normalizes form controls without side effects.
<link href="https://unpkg.com/sanitize.css/forms.css" rel="stylesheet" />
A separate stylesheet that sizes form controls without affecting native styles.
<link href="https://unpkg.com/sanitize.css/formsize.css" rel="stylesheet" />
A separate stylesheet that normalizes typography using system interface fonts.
<link href="https://unpkg.com/sanitize.css/typography.css" rel="stylesheet" />
A separate stylesheet that applies a comfortable measure to the page.
<link href="https://unpkg.com/sanitize.css/measure.css" rel="stylesheet" />
npm install --save sanitize.css
Import sanitize.css in CSS:
@import 'sanitize.css';
@import 'sanitize.css/typography.css';
@import 'sanitize.css/forms.css';
Alternatively, import sanitize.css in JS:
import 'sanitize.css';
import 'sanitize.css/typography.css';
import 'sanitize.css/forms.css';
In webpack.config.js
, be sure to use the appropriate loaders:
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
}
]
}
}
*, ::before, ::after {
box-sizing: border-box;
}
*, ::before, ::after {
background-repeat: no-repeat;
}
::before,
::after {
text-decoration: inherit;
vertical-align: inherit;
}
html {
cursor: default;
}
html {
line-height: 1.5;
}
html {
tab-size: 4;
}
html {
word-break: break-all;
}
body {
margin: 0;
}
nav ol, nav ul {
list-style: none;
padding: 0;
}
audio, canvas, iframe, img, svg, video {
vertical-align: middle;
}
svg:not([fill]) {
fill: currentColor;
}
table {
border-collapse: collapse;
}
textarea {
resize: vertical;
}
a, area, button, input, label, select, summary, textarea, [tabindex] {
-ms-touch-action: manipulation;
touch-action: manipulation;
}
[aria-busy="true"] {
cursor: progress;
}
[aria-controls] {
cursor: pointer;
}
[aria-disabled="true"], [disabled] {
cursor: default;
}
[aria-hidden="false"][hidden] {
display: initial;
}
[aria-hidden="false"][hidden]:not(:focus) {
clip: rect(0, 0, 0, 0);
position: absolute;
}
sanitize.css includes a separate stylesheet for normalizing typography using system interface fonts.
sanitize.css includes a separate stylesheet for normalizing forms using minimal, standards-like styling.
Browser
<link href="https://unpkg.com/sanitize.css/typography.css" rel="stylesheet" />
Download
See https://csstools.github.io/sanitize.css/latest/typography.css
CDN
see https://cdnjs.com/libraries/10up-sanitize.css/typography.css
html {
font-family:
system-ui,
/* macOS 10.11-10.12 */ -apple-system,
/* Windows 6+ */ Segoe UI,
/* Android 4+ */ Roboto,
/* Ubuntu 10.10+ */ Ubuntu,
/* Gnome 3+ */ Cantarell,
/* KDE Plasma 5+ */ Noto Sans,
/* fallback */ sans-serif,
/* macOS emoji */ "Apple Color Emoji",
/* Windows emoji */ "Segoe UI Emoji",
/* Windows emoji */ "Segoe UI Symbol",
/* Linux emoji */ "Noto Color Emoji";
}
code, kbd, pre, samp {
font-family:
/* macOS 10.10+ */ Menlo,
/* Windows 6+ */ Consolas,
/* Android 4+ */ Roboto Mono,
/* Ubuntu 10.10+ */ Ubuntu Monospace,
/* KDE Plasma 5+ */ Noto Mono,
/* KDE Plasma 4+ */ Oxygen Mono,
/* Linux/OpenOffice fallback */ Liberation Mono,
/* fallback */ monospace;
}
normalize.css and sanitize.css correct browser bugs while carefully testing and documenting changes. normalize.css styles adhere to css specifications. sanitize.css styles adhere to common developer expectations and preferences. reset.css unstyles all elements. Both sanitize.css and normalize.css are maintained in sync.
Please read the contribution guidelines in order to make the contribution process easy and effective for everyone involved.
sanitize.css is a project by Jonathan Neal, built upon normalize.css, a project by Jonathan Neal, co-created with Nicolas Gallagher.