# Tailwind CSS v4 Reference
## Quick Start
```css
@import "tailwindcss";
```
```html
Hello World
```
---
## Core Syntax
| Pattern | Example | Description |
|---------|---------|-------------|
| `{utility}` | `flex` | Base utility |
| `{variant}:{utility}` | `hover:bg-blue-500` | Conditional application |
| `{utility}-{value}` | `p-4`, `text-lg` | Value from scale |
| `{utility}-[{value}]` | `p-[13px]`, `grid-cols-[1fr_2fr]` | Arbitrary value |
| `{utility}-(--var)` | `p-(--my-spacing)` | CSS variable shorthand |
| `{utility}-({type}:--var)` | `text-(color:--my-var)` | Type hint + variable shorthand |
| `{utility}-[{type}:{value}]` | `text-[color:var(--my-var)]` | Type hint for arbitrary values |
| `{utility}/{opacity}` | `bg-black/50`, `text-white/75` | Opacity modifier |
| `-{utility}` | `-mt-4`, `-translate-x-2` | Negative value |
| `{utility}!` | `hidden!`, `flex!` | !important modifier |
### Stacking Variants
Variants stack left-to-right: `dark:md:hover:bg-blue-500`
### Type Hints
When a utility namespace is ambiguous (e.g., `text-*` maps to both `font-size` and `color`), use type hints:
- `text-(length:--my-var)` or `text-[length:var(--my-var)]` → `font-size`
- `text-(color:--my-var)` or `text-[color:var(--my-var)]` → `color`
- `bg-(url:--my-img)` or `bg-[url:var(--my-img)]` → `background-image`
---
## Variants Reference
### Pseudo-classes
| Variant | Selector |
|---------|----------|
| `hover` | `:hover` |
| `focus` | `:focus` |
| `focus-within` | `:focus-within` |
| `focus-visible` | `:focus-visible` |
| `active` | `:active` |
| `visited` | `:visited` |
| `target` | `:target` |
| `first` | `:first-child` |
| `last` | `:last-child` |
| `only` | `:only-child` |
| `odd` | `:nth-child(odd)` |
| `even` | `:nth-child(even)` |
| `first-of-type` | `:first-of-type` |
| `last-of-type` | `:last-of-type` |
| `only-of-type` | `:only-of-type` |
| `nth-{n}` | `:nth-child({n})` |
| `nth-last-{n}` | `:nth-last-child({n})` |
| `nth-of-type-{n}` | `:nth-of-type({n})` |
| `nth-last-of-type-{n}` | `:nth-last-of-type({n})` |
| `empty` | `:empty` |
| `disabled` | `:disabled` |
| `enabled` | `:enabled` |
| `checked` | `:checked` |
| `indeterminate` | `:indeterminate` |
| `default` | `:default` |
| `optional` | `:optional` |
| `required` | `:required` |
| `valid` | `:valid` |
| `invalid` | `:invalid` |
| `user-valid` | `:user-valid` |
| `user-invalid` | `:user-invalid` |
| `in-range` | `:in-range` |
| `out-of-range` | `:out-of-range` |
| `placeholder-shown` | `:placeholder-shown` |
| `autofill` | `:autofill` |
| `read-only` | `:read-only` |
| `has-*` | `:has()` — e.g., `has-[:checked]`, `has-[img]`, `has-checked` |
| `not-*` | `:not()` — e.g., `not-hover`, `not-focus`, `not-disabled` |
### Pseudo-elements
| Variant | Selector |
|---------|----------|
| `before` | `::before` (auto adds `content: ''`) |
| `after` | `::after` (auto adds `content: ''`) |
| `placeholder` | `::placeholder` |
| `file` | `::file-selector-button` |
| `marker` | `::marker` |
| `selection` | `::selection` |
| `first-line` | `::first-line` |
| `first-letter` | `::first-letter` |
| `backdrop` | `::backdrop` |
| `details-content` | `::details-content` |
### Media Queries
| Variant | Media Query |
|---------|-------------|
| `sm` | `width >= 40rem` (640px) |
| `md` | `width >= 48rem` (768px) |
| `lg` | `width >= 64rem` (1024px) |
| `xl` | `width >= 80rem` (1280px) |
| `2xl` | `width >= 96rem` (1536px) |
| `max-sm` | `width < 40rem` |
| `max-md` | `width < 48rem` |
| `max-lg` | `width < 64rem` |
| `max-xl` | `width < 80rem` |
| `max-2xl` | `width < 96rem` |
| `min-[{value}]` | `width >= {value}` |
| `max-[{value}]` | `width < {value}` |
| `dark` | `prefers-color-scheme: dark` |
| `light` | `prefers-color-scheme: light` |
| `motion-safe` | `prefers-reduced-motion: no-preference` |
| `motion-reduce` | `prefers-reduced-motion: reduce` |
| `contrast-more` | `prefers-contrast: more` |
| `contrast-less` | `prefers-contrast: less` |
| `forced-colors` | `forced-colors: active` |
| `not-forced-colors` | `forced-colors: none` |
| `inverted-colors` | `inverted-colors: inverted` |
| `portrait` | `orientation: portrait` |
| `landscape` | `orientation: landscape` |
| `print` | `print` |
| `noscript` | `scripting: none` |
| `pointer-fine` | `pointer: fine` |
| `pointer-coarse` | `pointer: coarse` |
| `pointer-none` | `pointer: none` |
| `any-pointer-fine` | `any-pointer: fine` |
| `any-pointer-coarse` | `any-pointer: coarse` |
Negate with `not-` prefix: `not-dark`, `not-print`, `not-forced-colors`, etc.
### Container Queries
| Variant | Min-width |
|---------|-----------|
| `@3xs` | 16rem |
| `@2xs` | 18rem |
| `@xs` | 20rem |
| `@sm` | 24rem |
| `@md` | 28rem |
| `@lg` | 32rem |
| `@xl` | 36rem |
| `@2xl` | 42rem |
| `@3xl` | 48rem |
| `@4xl` | 56rem |
| `@5xl` | 64rem |
| `@6xl` | 72rem |
| `@7xl` | 80rem |
| `@[{value}]` | `width >= {value}` |
| `@max-[{value}]` | `width < {value}` |
Container: `@container` class on parent, or `@container/{name}` for named containers.
### State Variants
| Variant | Description |
|---------|-------------|
| `open` | `` or `