Preflight and Base Styles
|
This section documents Tailwind CSS v4.x — the CSS-first configuration line, whose v4.0 release shipped in January 2025 — as published at the official Tailwind CSS documentation, which is the reference these pages are written and verified against. No specific patch version is pinned. This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production, since Tailwind iterates quickly. This section’s bibliography lists the reference material consulted while preparing these pages. |
Preflight is Tailwind’s opinionated base layer — a cross-browser reset built on top of
modern-normalize that removes the browser’s default styling so utilities
have a predictable starting point. It is emitted into the base cascade layer, so any real CSS you write later
overrides it easily. See Preflight.
What Preflight resets
| Change | Effect |
|---|---|
Margins removed |
|
Headings unstyled |
|
Lists unstyled |
|
Borders reset |
Every element gets |
Media block-level |
|
Media constrained |
|
Form controls |
|
|
An element with the |
/* a representative slice of what Preflight emits into @layer base */
*, ::after, ::before, ::backdrop {
box-sizing: border-box;
border: 0 solid;
margin: 0;
padding: 0;
}
h1, h2, h3, h4, h5, h6 { font-size: inherit; font-weight: inherit; }
ol, ul, menu { list-style: none; }
img, svg, video, canvas, audio, iframe, embed, object { display: block; vertical-align: middle; }
img, video { max-width: 100%; height: auto; }
It ships automatically
Preflight is part of the single import — there is no separate include:
@import "tailwindcss";
/* expands to:
@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/preflight.css" layer(base);
@import "tailwindcss/utilities.css" layer(utilities); */
Extending Preflight
Add your own element-level defaults in @layer base. Because these land in the same layer as Preflight, later
utilities still override them. Use theme variables for the values so the defaults track your design tokens.
@import "tailwindcss";
@layer base {
h1 { font-size: var(--text-2xl); font-weight: var(--font-weight-bold); }
h2 { font-size: var(--text-xl); }
a { color: var(--color-sky-600); text-decoration-line: underline; }
/* restore readable defaults inside CMS / Markdown output */
.prose-fallback :is(ul, ol) { list-style: revert; padding-left: revert; }
}
See Adding base styles.
Disabling or partially adopting Preflight
Import the layers individually and simply omit preflight.css:
/* theme variables + utilities, but no reset */
@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/utilities.css" layer(utilities);
When you split the import like this, options that normally attach to @import "tailwindcss" move to the
relevant sub-import: source(…) and important go on the utilities.css line, theme(static) /
theme(inline) on the theme.css line, and prefix(…) on both. This is the usual approach when adding
Tailwind to an existing codebase that already has its own reset, or when embedding a Tailwind-styled widget
inside a host page you do not control.
Related pages
-
Theme Variables and Colors — the
themelayer and the variables the base styles above reference. -
Customization and Configuration — the full cascade-layer model and
@layerusage. -
The Box Model — the
box-sizing: border-boxreset in plain-CSS terms.