CSS Reference — Complete Cheat Sheet, Properties & Browser Support
This is your complete CSS reference — a cheat sheet of selectors, properties, units, and tools for quick lookup. Bookmark this page and come back whenever you need to remember a syntax.
What You’ll Find
By the end of this reference, you’ll have a comprehensive catalog of CSS selectors (including modern ones like :has() and :is()), layout and box model properties, typography properties (font-family, font-size, text-align), animation properties, all CSS units, browser support for major features, and an overview of CSS frameworks and preprocessors (Sass, Less, PostCSS).
Where This Fits
flowchart LR
A["All CSS Tutorials"] --> B["**CSS Reference**"]
B --> C["Frameworks & Libraries"]
C --> D["Frontend-Ready Developer"]
style B fill:#f97316,stroke:#c2410c,color:#fff
style A fill:#e5e7eb,stroke:#9ca3af,color:#374151
style D fill:#22c55e,stroke:#16a34a,color:#fff
CSS Selectors Cheat Sheet
| Selector | Example | What It Targets |
|---|---|---|
* | * { } | Every element |
element | p { } | All <p> elements |
.class | .card { } | Elements with class="card" |
#id | #header { } | Element with id="header" |
[attr] | [disabled] { } | Elements with that attribute |
[attr="v"] | [type="text"] { } | Exact attribute match |
[attr^="v"] | [href^="https"] { } | Attribute starts with value |
[attr$="v"] | [src$=".jpg"] { } | Attribute ends with value |
[attr*="v"] | [class*="btn"] { } | Attribute contains value anywhere |
:hover | a:hover { } | Mouse is over the element |
:focus | input:focus { } | Element is focused (any method) |
:focus-visible | button:focus-visible { } | Focused via keyboard only |
:nth-child(n) | li:nth-child(2) { } | Nth child of its parent |
:nth-of-type(n) | p:nth-of-type(2) { } | Nth of that element type |
:first-child | li:first-child { } | First child |
:last-child | li:last-child { } | Last child |
:not() | :not(.hidden) { } | Negation |
:has() | .card:has(img) { } | Parent containing a child matching selector |
:is() | :is(h1, h2) { } | Group (forgiving) |
:empty | div:empty { } | Element with no children |
::before | .note::before { } | Insert content before element |
::after | .note::after { } | Insert content after element |
::placeholder | input::placeholder { } | Placeholder text |
::selection | ::selection { } | User-selected text |
(space) | div p { } | Descendant (any depth) |
> | div > p { } | Direct child |
+ | h2 + p { } | Adjacent sibling |
~ | h2 ~ p { } | General sibling |
, | h1, h2, h3 { } | Group multiple selectors |
Properties Quick Reference
Layout
| Property | Common Values |
|---|---|
display | block, inline, inline-block, flex, grid, none, contents |
position | static, relative, absolute, fixed, sticky |
top, right, bottom, left | <length>, auto |
z-index | <number> |
float | left, right, none |
clear | left, right, both, none |
overflow | visible, hidden, scroll, auto, clip |
overflow-x, overflow-y | visible, hidden, scroll, auto |
Box Model
| Property | Common Values |
|---|---|
width, height | <length>, auto, min-content, max-content, fit-content |
min-width, max-width | <length> |
min-height, max-height | <length> |
padding | <size> (shorthand: top, right, bottom, left) |
margin | <size>, auto |
border | <width> <style> <color> |
border-radius | <size> (up to 4 values for each corner) |
box-sizing | content-box, border-box |
Typography
| Property | Common Values |
|---|---|
font-family | <font-name>, serif, sans-serif, monospace, system-ui |
font-size | <size>, small, medium, large, larger, smaller |
font-weight | normal, bold, 100-900 |
font-style | normal, italic, oblique |
line-height | <number>, <length>, normal |
text-align | left, center, right, justify |
text-decoration | none, underline, line-through, overline |
text-transform | uppercase, lowercase, capitalize, none |
color | <color> |
letter-spacing | <length> |
word-spacing | <length> |
white-space | normal, nowrap, pre, pre-wrap, pre-line |
word-break | normal, break-all, keep-all |
Background & Visual
| Property | Common Values |
|---|---|
background | Shorthand: <color> <image> <repeat> <position> / <size> <attachment> |
background-color | <color>, transparent |
background-image | url(...), linear-gradient(...), radial-gradient(...) |
background-size | auto, cover, contain, <length> |
background-position | center, top left, <x> <y> |
background-repeat | no-repeat, repeat, repeat-x, repeat-y |
box-shadow | <x> <y> <blur> <spread> <color>, inset ... |
text-shadow | <x> <y> <blur> <color> |
opacity | 0 to 1 |
filter | blur(), brightness(), grayscale(), sepia(), saturate(), hue-rotate() |
clip-path | circle(), polygon(), inset(), url(...) |
Flexbox
| Property | Common Values |
|---|---|
display | flex |
flex-direction | row, row-reverse, column, column-reverse |
flex-wrap | nowrap, wrap, wrap-reverse |
flex-flow | Shorthand: <direction> <wrap> |
justify-content | flex-start, center, flex-end, space-between, space-around, space-evenly |
align-items | stretch, center, flex-start, flex-end, baseline |
align-content | stretch, center, flex-start, flex-end, space-between, space-around |
gap | <size> |
flex | Shorthand: <grow> <shrink> <basis> |
flex-grow | <number> |
flex-shrink | <number> |
flex-basis | <length>, auto |
align-self | auto, stretch, center, flex-start, flex-end, baseline |
order | <number> |
Grid
| Property | Common Values |
|---|---|
display | grid |
grid-template-columns | <sizes>, repeat(n, size), auto-fill, auto-fit |
grid-template-rows | <sizes> |
grid-template-areas | "header header" "sidebar main" |
gap | <row-gap> <column-gap> |
grid-column | <start> / <end> |
grid-row | <start> / <end> |
grid-area | <name>, or <row-start> / <col-start> / <row-end> / <col-end> |
place-items | <align> <justify> |
place-content | <align> <justify> |
place-self | <align> <justify> |
Animation
| Property | Common Values |
|---|---|
transition | Shorthand: <property> <duration> <timing> <delay> |
transition-property | all, opacity, transform, background, color |
transition-duration | <time> (0.3s, 200ms) |
transition-timing-function | ease, linear, ease-in, ease-out, ease-in-out, cubic-bezier(n,n,n,n) |
transform | translate(x, y), rotate(deg), scale(n), skew(deg) |
transform-origin | center, top left, <x> <y> |
animation | Shorthand: <name> <duration> <timing> <delay> <count> <direction> <fill-mode> |
animation-name | @keyframes name |
animation-duration | <time> |
animation-iteration-count | <number>, infinite |
animation-direction | normal, reverse, alternate, alternate-reverse |
animation-fill-mode | none, forwards, backwards, both |
animation-play-state | running, paused |
CSS Units
| Unit | Relative To | Best For |
|---|---|---|
px | Screen pixel | Borders, small offsets, shadows |
% | Parent element | Widths, heights, padding/margin based on parent |
em | Current element’s font-size | Paddings that scale with text size |
rem | Root (<html>) font-size | Font sizes, spacing, consistent across page |
vw | Viewport width (1vw = 1%) | Full-width sections, hero layouts |
vh | Viewport height (1vh = 1%) | Full-screen sections, sticky elements |
vmin | Smaller viewport axis | Responsive sizing that respects orientation |
vmax | Larger viewport axis | Responsive sizing |
ch | Width of “0” character | Line length limits (max-width: 60ch for readability) |
fr | Available space in grid | Grid track sizing |
pt | 1pt = 1/72 inch | Print stylesheets |
Browser Support
| Feature | Chrome | Firefox | Safari | Edge | Notes |
|---|---|---|---|---|---|
| Flexbox | ✅ | ✅ | ✅ | ✅ | Old Safari needs -webkit- |
| Grid | ✅ | ✅ | ✅ | ✅ | IE11 partial |
| CSS Variables | ✅ | ✅ | ✅ | ✅ | Not in IE11 |
| Container Queries | 105+ | 110+ | 16+ | 105+ | Modern feature |
:has() | 105+ | 121+ | 15.4+ | 105+ | Parent selector |
@property | 85+ | 128+ | 15.4+ | 85+ | Houdini |
backdrop-filter | 76+ | 103+ | 12.1+ | 76+ | Glass effects |
scroll-snap | ✅ | ✅ | ✅ | ✅ | Well supported |
subgrid | 117+ | 71+ | 16+ | 117+ | Partial |
aspect-ratio | ✅ | ✅ | ✅ | ✅ | Well supported |
accent-color | 93+ | 92+ | 15.4+ | 93+ | Form controls |
Check latest support at caniuse.com.
CSS Frameworks
| Framework | Approach | Best For |
|---|---|---|
| Bootstrap | Utility + component classes | Rapid prototyping, consistent UI |
| Tailwind CSS | Utility-first | Custom designs, small bundles |
| Bulma | Flexbox-based, semantic | Clean, modern designs |
| Foundation | Responsive framework | Enterprise sites, email |
| Pure CSS | Minimal, tiny | Small projects |
| Open Props | Design tokens | Custom design systems |
CSS Preprocessors
Sass / SCSS
$primary: #3498db;
$spacing: 16px;
.card {
background: white;
padding: $spacing;
.title {
color: $primary;
font-size: 1.25rem;
}
&:hover {
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
}Less
@primary: #3498db;
.card {
background: white;
.title { color: @primary; }
}PostCSS
A tool for transforming CSS with plugins — Autoprefixer, nesting, future CSS syntax.
Common Mistakes Beginners Make
1. Skipping the Fundamentals
Many beginners jump straight to advanced topics without mastering the basics. Take time to understand the core concepts before moving on.
2. Not Practicing Enough
Reading tutorials without writing code leads to shallow understanding. Code along with every example and experiment on your own.
3. Ignoring Error Messages
Error messages tell you exactly what went wrong. Read them carefully — they usually point to the line and type of issue.
4. Copy-Pasting Without Understanding
It’s tempting to copy code from tutorials, but typing it yourself and understanding each line builds real skill.
5. Giving Up Too Early
Every developer hits frustrating bugs. Take breaks, ask for help, and remember that struggling is part of learning.
Practice Questions
Q1: What’s the difference between :nth-child and :nth-of-type?:nth-child(2) selects the second child regardless of element type. :nth-of-type(2) selects the second element of that specific type.
Q2: Which units are best for responsive font sizes?rem for consistent sizing across the page. clamp(min, preferred, max) for fluid typography. em for sizes relative to the current element.
Q3: What does Makes box-sizing: border-box do?width and height include padding and border in their calculation, so a 100px-wide element stays 100px regardless of padding.
Q4: What’s the difference between transition and animation?transition animates between two states (triggered by hover, focus, etc.). animation with @keyframes can define multiple steps and loop.
Q5: What’s a CSS preprocessor? A tool that extends CSS with variables, nesting, mixins, and functions. Sass (SCSS) and Less are the most popular. They compile to standard CSS.
FAQ
{< faq >}
- What is Css Reference?
- Css Reference refers to the core concepts and practices used to build and manage modern web applications. Understanding it is essential for web developers.
- Do I need prior experience to learn Css Reference?
- Basic familiarity with web development concepts helps, but Css Reference can be learned step by step even as a beginner.
- How long does it take to learn Css Reference?
- With consistent practice, you can grasp the fundamentals in a few days to a week. Mastery takes ongoing practice and real-world projects.
- Where can I use Css Reference in real projects?
- Css Reference is used in a wide range of applications — from simple websites to complex enterprise systems, depending on the specific tools and technologies involved.
- What are common tools used with Css Reference?
- The specific tools depend on the technology stack, but version control (Git), package managers, and testing frameworks are commonly used alongside most development topics.
{< /faq >}
FAQ
What’s Next?
You’ve completed the CSS module! Continue to:
What’s Next
Congratulations on completing this Css Reference tutorial! Here’s where to go from here:
- Practice daily — Consistency is more important than long study sessions
- Build a project — Apply what you learned by building something real
- Explore related topics — Check out other tutorials in the same category
- Join the community — Discuss with other learners and share your progress
Remember: every expert was once a beginner. Keep coding!
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro