Edit the CSS below and click Run. The preview updates instantly so you can test styles quickly.
--accent and verify button/title color update together.CSS HOME
Start here: what CSS is, how it works, and how this tutorial is organized.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
*,*::before,*::after { | Targets elements matching: *,*::before,*::after. |
box-sizing:border-box | Sets `box-sizing` to `border-box`. |
} | Ends the current rule block. |
body { | Targets elements matching: body. |
margin:0; | Sets `margin` to `0`. |
font-family:system-ui,Arial,sans-serif | Sets `font-family` to `system-ui,Arial,sans-serif`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css tutorial css basics learn css stylesheets web designCSS Introduction
CSS (Cascading Style Sheets) controls how HTML looks: colors, spacing, typography, and layout.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
h1 { | Targets elements matching: h1. |
color:rebeccapurple | Sets `color` to `rebeccapurple`. |
} | Ends the current rule block. |
p { | Targets elements matching: p. |
line-height:1.7 | Sets `line-height` to `1.7`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
what is css css introduction css basics html css stylesheetCSS Syntax
A CSS rule is: selector + { property: value; }. Multiple rules cascade together.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.card { | Targets elements matching: .card. |
padding:16px; | Sets `padding` to `16px`. |
border:1px solid #e5e7eb; | Sets `border` to `1px solid #e5e7eb`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css syntax selectors properties values rulesCSS Selectors
Selectors target elements (by tag, class, id, attributes, states) so you can style them.
.btn { ... }
#hero { ... }
input[type="email"] { ... }
.btn:hover { ... }
.btn::before { ... }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
button.primary { | Targets elements matching: button.primary. |
background:#0ea5e9; | Sets `background` to `#0ea5e9`. |
color:#fff | Sets `color` to `#fff`. |
} | Ends the current rule block. |
#hero { | Targets elements matching: #hero. |
padding:24px | Sets `padding` to `24px`. |
} | Ends the current rule block. |
input[type="email"] { | Targets elements matching: input[type="email"]. |
border:1px solid #94a3b8 | Sets `border` to `1px solid #94a3b8`. |
} | Ends the current rule block. |
- 1Target buttons/links/forms precisely without adding extra HTML.
- 2Build reusable component classes instead of styling every tag globally.
- 1Using IDs everywhere (high specificity, hard to override).
- 2Writing overly long selectors that are fragile.
- 1Prefer class selectors for components.
- 2Keep specificity low; override by placing rules later or using a parent class.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css selectors class selector id selector attribute selector pseudo classCSS How To
Use CSS inline, in a <style> tag, or in an external .css file (best for real websites).
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
<link rel="stylesheet" href="styles.css"> | CSS statement. |
<!-- OR --> | CSS statement. |
<style> .btn { | Targets elements matching: <style> .btn. |
padding:10px 14px | Sets `padding` to `10px 14px`. |
} | Ends the current rule block. |
</style> | CSS statement. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
add css external stylesheet internal css inline css link cssCSS Comments
Comments help you document styles and temporarily disable rules while testing.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.btn { | Targets elements matching: .btn. |
background:#22c55e | Sets `background` to `#22c55e`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css comments comment css debug css disable css readable cssCSS Errors
Most CSS “bugs” come from typos, invalid values, missing units, and specificity conflicts.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.box { | Targets elements matching: .box. |
width:200 | Sets `width` to `200`. |
} | Ends the current rule block. |
.title { | Targets elements matching: .title. |
colorr:tomato | Sets `colorr` to `tomato`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css errors css debugging invalid property specificity devtoolsCSS Colors
CSS supports named colors, hex, rgb/rgba, hsl/hsla, and modern color functions.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.badge { | Targets elements matching: .badge. |
color:#0f172a; | Sets `color` to `#0f172a`. |
background:#ffd54f | Sets `background` to `#ffd54f`. |
} | Ends the current rule block. |
.overlay { | Targets elements matching: .overlay. |
background:rgba(2,6,23,.6) | Sets `background` to `rgba(2,6,23,.6)`. |
} | Ends the current rule block. |
.brand { | Targets elements matching: .brand. |
color:hsl(190 95% 45%) | Sets `color` to `hsl(190 95% 45%)`. |
} | Ends the current rule block. |
- 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
- 2Gradients and shadows can replace image assets for simple UI depth.
- 1Low contrast text (hard to read).
- 2Overusing heavy shadows and making UI look blurry.
- 1Aim for readable contrast; test quickly by lowering screen brightness.
- 2Prefer soft, low-opacity shadows and avoid stacking many effects.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css colors hex color rgb hsl rgbaCSS Backgrounds
Backgrounds can be solid, gradients, or images, and you control size, repeat, and position.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.hero { | Targets elements matching: .hero. |
background:linear-gradient(135deg,#1d4ed8,#0ea5e9); | Sets `background` to `linear-gradient(135deg,#1d4ed8,#0ea5e9)`. |
background-size:cover; | Sets `background-size` to `cover`. |
} | Ends the current rule block. |
- 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
- 2Gradients and shadows can replace image assets for simple UI depth.
- 1Low contrast text (hard to read).
- 2Overusing heavy shadows and making UI look blurry.
- 1Aim for readable contrast; test quickly by lowering screen brightness.
- 2Prefer soft, low-opacity shadows and avoid stacking many effects.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css background background image background size background position coverCSS Borders
Borders surround elements; you can change width, style, color, and radius.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.card { | Targets elements matching: .card. |
border:1px solid rgba(148,163,184,.5); | Sets `border` to `1px solid rgba(148,163,184,.5)`. |
border-radius:14px; | Sets `border-radius` to `14px`. |
} | Ends the current rule block. |
- 1Consistent spacing and borders make layouts feel clean and professional.
- 2Focus outlines improve keyboard usability.
- 1Forgetting `box-sizing: border-box` and getting unexpected widths.
- 2Using large fixed padding on small screens.
- 1Set `*,*::before,*::after{box-sizing:border-box}` early.
- 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css border border radius border styles outline box modelCSS Margins
Margin is the space outside an element. Use it to separate components.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.stack > * + * { | Targets elements matching: .stack > * + *. |
margin-top:12px | Sets `margin-top` to `12px`. |
} | Ends the current rule block. |
.center { | Targets elements matching: .center. |
margin:0 auto; | Sets `margin` to `0 auto`. |
max-width:900px | Sets `max-width` to `900px`. |
} | Ends the current rule block. |
- 1Consistent spacing and borders make layouts feel clean and professional.
- 2Focus outlines improve keyboard usability.
- 1Forgetting `box-sizing: border-box` and getting unexpected widths.
- 2Using large fixed padding on small screens.
- 1Set `*,*::before,*::after{box-sizing:border-box}` early.
- 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css margin margin shorthand spacing layout box modelCSS Padding
Padding is the space inside an element, between its content and border.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.btn { | Targets elements matching: .btn. |
padding:10px 14px | Sets `padding` to `10px 14px`. |
} | Ends the current rule block. |
.card { | Targets elements matching: .card. |
padding:18px 20px | Sets `padding` to `18px 20px`. |
} | Ends the current rule block. |
- 1Consistent spacing and borders make layouts feel clean and professional.
- 2Focus outlines improve keyboard usability.
- 1Forgetting `box-sizing: border-box` and getting unexpected widths.
- 2Using large fixed padding on small screens.
- 1Set `*,*::before,*::after{box-sizing:border-box}` early.
- 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css padding padding shorthand spacing box model ui spacingCSS Height / Width
Set explicit sizes with width/height, or use responsive sizing with %, vw, and max-width.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.panel { | Targets elements matching: .panel. |
width:min(92vw,720px); | Sets `width` to `min(92vw,720px)`. |
min-height:220px | Sets `min-height` to `220px`. |
} | Ends the current rule block. |
.avatar { | Targets elements matching: .avatar. |
width:48px; | Sets `width` to `48px`. |
height:48px; | Sets `height` to `48px`. |
border-radius:999px | Sets `border-radius` to `999px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css width css height responsive sizing max width min heightCSS Box Model
Every element is a box: content → padding → border → margin. This affects layout and sizing.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
*,*::before,*::after { | Targets elements matching: *,*::before,*::after. |
box-sizing:border-box | Sets `box-sizing` to `border-box`. |
} | Ends the current rule block. |
- 1Consistent spacing and borders make layouts feel clean and professional.
- 2Focus outlines improve keyboard usability.
- 1Forgetting `box-sizing: border-box` and getting unexpected widths.
- 2Using large fixed padding on small screens.
- 1Set `*,*::before,*::after{box-sizing:border-box}` early.
- 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css box model margin padding border contentCSS Outline
Outline does not take layout space. It’s perfect for focus styles and accessibility.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
a:focus-visible { | Targets elements matching: a:focus-visible. |
outline:3px solid #ffd54f; | Sets `outline` to `3px solid #ffd54f`. |
outline-offset:4px; | Sets `outline-offset` to `4px`. |
} | Ends the current rule block. |
- 1Consistent spacing and borders make layouts feel clean and professional.
- 2Focus outlines improve keyboard usability.
- 1Forgetting `box-sizing: border-box` and getting unexpected widths.
- 2Using large fixed padding on small screens.
- 1Set `*,*::before,*::after{box-sizing:border-box}` early.
- 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css outline focus visible accessibility keyboard navigation uiCSS Text
Text styling covers alignment, spacing, decoration, and overflow handling.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.title { | Targets elements matching: .title. |
letter-spacing:-.5px | Sets `letter-spacing` to `-.5px`. |
} | Ends the current rule block. |
.center { | Targets elements matching: .center. |
text-align:center | Sets `text-align` to `center`. |
} | Ends the current rule block. |
.ellipsis { | Targets elements matching: .ellipsis. |
white-space:nowrap; | Sets `white-space` to `nowrap`. |
overflow:hidden; | Sets `overflow` to `hidden`. |
text-overflow:ellipsis | Sets `text-overflow` to `ellipsis`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css text text align line height letter spacing text overflowCSS Fonts
Choose readable fonts, control size/weight, and use fallbacks for reliability.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
body { | Targets elements matching: body. |
font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif | Sets `font-family` to `system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif`. |
} | Ends the current rule block. |
code { | Targets elements matching: code. |
font-family:ui-monospace,Consolas,monospace | Sets `font-family` to `ui-monospace,Consolas,monospace`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css fonts font family font weight typography web fontsCSS Icons
Icons are commonly delivered via SVG or icon fonts; style them with color and size.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.icon { | Targets elements matching: .icon. |
width:18px; | Sets `width` to `18px`. |
height:18px; | Sets `height` to `18px`. |
fill:currentColor | Sets `fill` to `currentColor`. |
} | Ends the current rule block. |
.icon-btn { | Targets elements matching: .icon-btn. |
display:inline-flex; | Sets `display` to `inline-flex`. |
gap:8px; | Sets `gap` to `8px`. |
align-items:center | Sets `align-items` to `center`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css icons svg icon icon font font awesome inline svgCSS Links
Style links for normal/hover/visited/focus states. Keep enough contrast and underline on hover.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
a { | Targets elements matching: a. |
color:#00e5ff; | Sets `color` to `#00e5ff`. |
text-decoration:none | Sets `text-decoration` to `none`. |
} | Ends the current rule block. |
a:hover { | Targets elements matching: a:hover. |
text-decoration:underline | Sets `text-decoration` to `underline`. |
} | Ends the current rule block. |
a:focus-visible { | Targets elements matching: a:focus-visible. |
outline:2px solid #ffd54f; | Sets `outline` to `2px solid #ffd54f`. |
outline-offset:3px | Sets `outline-offset` to `3px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css links hover visited focus visible underlineCSS Lists
Control markers, spacing, and make modern menus by removing default list styles.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
ul.nav { | Targets elements matching: ul.nav. |
list-style:none; | Sets `list-style` to `none`. |
margin:0; | Sets `margin` to `0`. |
padding:0; | Sets `padding` to `0`. |
display:flex; | Sets `display` to `flex`. |
gap:12px | Sets `gap` to `12px`. |
} | Ends the current rule block. |
ul.nav a { | Targets elements matching: ul.nav a. |
padding:8px 10px; | Sets `padding` to `8px 10px`. |
border-radius:10px | Sets `border-radius` to `10px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css lists list style ul li navigation markersCSS Tables
Tables need spacing, borders, and zebra rows to be readable.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
table { | Targets elements matching: table. |
border-collapse:collapse; | Sets `border-collapse` to `collapse`. |
width:100% | Sets `width` to `100%`. |
} | Ends the current rule block. |
th,td { | Targets elements matching: th,td. |
border:1px solid #334155; | Sets `border` to `1px solid #334155`. |
padding:10px | Sets `padding` to `10px`. |
} | Ends the current rule block. |
tr:nth-child(even) { | Targets elements matching: tr:nth-child(even). |
background:rgba(148,163,184,.08) | Sets `background` to `rgba(148,163,184,.08)`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css tables table styling border collapse zebra rows responsive tableCSS Display
display controls layout behavior: block, inline, inline-block, flex, grid, none.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.pill { | Targets elements matching: .pill. |
display:inline-block; | Sets `display` to `inline-block`. |
padding:6px 10px; | Sets `padding` to `6px 10px`. |
border-radius:999px | Sets `border-radius` to `999px`. |
} | Ends the current rule block. |
.hidden { | Targets elements matching: .hidden. |
display:none | Sets `display` to `none`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css display block inline inline-block noneCSS Max-width
max-width prevents content from stretching too wide and improves readability.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.container { | Targets elements matching: .container. |
max-width:1100px; | Sets `max-width` to `1100px`. |
margin:0 auto; | Sets `margin` to `0 auto`. |
padding:0 16px | Sets `padding` to `0 16px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css max width responsive layout readability container fluidCSS Position
position lets you offset elements relative to normal flow (relative/absolute/fixed/sticky).
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.badge { | Targets elements matching: .badge. |
position:absolute; | Sets `position` to `absolute`. |
top:10px; | Sets `top` to `10px`. |
right:10px | Sets `right` to `10px`. |
} | Ends the current rule block. |
.sticky { | Targets elements matching: .sticky. |
position:sticky; | Sets `position` to `sticky`. |
top:0 | Sets `top` to `0`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css position relative absolute fixed stickyCSS Position Offsets
Offsets are top/right/bottom/left (or inset). They work when position is not static.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.box { | Targets elements matching: .box. |
position:relative; | Sets `position` to `relative`. |
left:12px; | Sets `left` to `12px`. |
top:6px | Sets `top` to `6px`. |
} | Ends the current rule block. |
.box2 { | Targets elements matching: .box2. |
position:absolute; | Sets `position` to `absolute`. |
inset:12px | Sets `inset` to `12px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css top css left inset offsets positionCSS Z-index
z-index controls stacking order, but only works on positioned elements/stacking contexts.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.modal { | Targets elements matching: .modal. |
position:fixed; | Sets `position` to `fixed`. |
inset:0; | Sets `inset` to `0`. |
z-index:50 | Sets `z-index` to `50`. |
} | Ends the current rule block. |
.toast { | Targets elements matching: .toast. |
position:fixed; | Sets `position` to `fixed`. |
bottom:16px; | Sets `bottom` to `16px`. |
right:16px; | Sets `right` to `16px`. |
z-index:60 | Sets `z-index` to `60`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css z-index stacking context position overlay modalCSS Overflow
overflow controls clipping and scrolling for content that exceeds its box.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.scroller { | Targets elements matching: .scroller. |
max-height:180px; | Sets `max-height` to `180px`. |
overflow:auto | Sets `overflow` to `auto`. |
} | Ends the current rule block. |
.clip { | Targets elements matching: .clip. |
overflow:hidden | Sets `overflow` to `hidden`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css overflow scroll hidden auto clipCSS Float
Float is mainly for wrapping text around images. Use Flexbox/Grid for layouts.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.pic { | Targets elements matching: .pic. |
float:left; | Sets `float` to `left`. |
margin:0 12px 10px 0; | Sets `margin` to `0 12px 10px 0`. |
width:120px | Sets `width` to `120px`. |
} | Ends the current rule block. |
.clearfix::after { | Targets elements matching: .clearfix::after. |
content:""; | Sets `content` to `""`. |
display:block; | Sets `display` to `block`. |
clear:both | Sets `clear` to `both`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css float clear legacy layout wrap text clearfixCSS Inline-block
inline-block flows inline like text but keeps block sizing (width/height).
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.tag { | Targets elements matching: .tag. |
display:inline-block; | Sets `display` to `inline-block`. |
padding:6px 10px; | Sets `padding` to `6px 10px`. |
border:1px solid #334155; | Sets `border` to `1px solid #334155`. |
border-radius:999px | Sets `border-radius` to `999px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
inline-block css display inline block layoutCSS Align
Alignment depends on layout mode: text-align for inline content; flex/grid for layouts.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.center-text { | Targets elements matching: .center-text. |
text-align:center | Sets `text-align` to `center`. |
} | Ends the current rule block. |
.row { | Targets elements matching: .row. |
display:flex; | Sets `display` to `flex`. |
justify-content:center; | Sets `justify-content` to `center`. |
align-items:center | Sets `align-items` to `center`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css align justify-content align-items text-align centerCSS Combinators
Combinators select elements by relationship: descendant, child, adjacent sibling, general sibling.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.card a { | Targets elements matching: .card a. |
color:#00e5ff | Sets `color` to `#00e5ff`. |
} | Ends the current rule block. |
ul > li { | Targets elements matching: ul > li. |
margin-top:6px | Sets `margin-top` to `6px`. |
} | Ends the current rule block. |
h2 + p { | Targets elements matching: h2 + p. |
margin-top:0 | Sets `margin-top` to `0`. |
} | Ends the current rule block. |
- 1Target buttons/links/forms precisely without adding extra HTML.
- 2Build reusable component classes instead of styling every tag globally.
- 1Using IDs everywhere (high specificity, hard to override).
- 2Writing overly long selectors that are fragile.
- 1Prefer class selectors for components.
- 2Keep specificity low; override by placing rules later or using a parent class.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css combinators descendant selector child selector adjacent sibling general siblingCSS Pseudo-classes
Pseudo-classes target states: :hover, :focus-visible, :checked, :nth-child() and more.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
button:hover { | Targets elements matching: button:hover. |
filter:brightness(1.05) | Sets `filter` to `brightness(1.05)`. |
} | Ends the current rule block. |
input:checked + label { | Targets elements matching: input:checked + label. |
font-weight:800 | Sets `font-weight` to `800`. |
} | Ends the current rule block. |
li:nth-child(odd) { | Targets elements matching: li:nth-child(odd). |
opacity:.9 | Sets `opacity` to `.9`. |
} | Ends the current rule block. |
- 1Target buttons/links/forms precisely without adding extra HTML.
- 2Build reusable component classes instead of styling every tag globally.
- 1Using IDs everywhere (high specificity, hard to override).
- 2Writing overly long selectors that are fragile.
- 1Prefer class selectors for components.
- 2Keep specificity low; override by placing rules later or using a parent class.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
pseudo class hover focus visible nth-child checkedCSS Pseudo-elements
Pseudo-elements style parts of elements: ::before, ::after, ::first-line, ::marker.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.pill::before { | Targets elements matching: .pill::before. |
content:"#"; | Sets `content` to `"#"`. |
opacity:.7; | Sets `opacity` to `.7`. |
margin-right:6px | Sets `margin-right` to `6px`. |
} | Ends the current rule block. |
li::marker { | Targets elements matching: li::marker. |
color:#ff4081 | Sets `color` to `#ff4081`. |
} | Ends the current rule block. |
- 1Target buttons/links/forms precisely without adding extra HTML.
- 2Build reusable component classes instead of styling every tag globally.
- 1Using IDs everywhere (high specificity, hard to override).
- 2Writing overly long selectors that are fragile.
- 1Prefer class selectors for components.
- 2Keep specificity low; override by placing rules later or using a parent class.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
pseudo element before after marker first-lineCSS Opacity
opacity affects an entire element (including children). For only background, use rgba().
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.muted { | Targets elements matching: .muted. |
opacity:.65 | Sets `opacity` to `.65`. |
} | Ends the current rule block. |
.overlay { | Targets elements matching: .overlay. |
background:rgba(2,6,23,.55) | Sets `background` to `rgba(2,6,23,.55)`. |
} | Ends the current rule block. |
- 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
- 2Gradients and shadows can replace image assets for simple UI depth.
- 1Low contrast text (hard to read).
- 2Overusing heavy shadows and making UI look blurry.
- 1Aim for readable contrast; test quickly by lowering screen brightness.
- 2Prefer soft, low-opacity shadows and avoid stacking many effects.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css opacity rgba transparent alpha overlayCSS Dropdowns
Dropdowns can be built with :hover or :focus-within. Prefer keyboard-friendly patterns.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.dd { | Targets elements matching: .dd. |
position:relative; | Sets `position` to `relative`. |
display:inline-block | Sets `display` to `inline-block`. |
} | Ends the current rule block. |
.dd-menu { | Targets elements matching: .dd-menu. |
display:none; | Sets `display` to `none`. |
position:absolute; | Sets `position` to `absolute`. |
top:100%; | Sets `top` to `100%`. |
left:0 | Sets `left` to `0`. |
} | Ends the current rule block. |
.dd:focus-within .dd-menu { | Targets elements matching: .dd:focus-within .dd-menu. |
display:block | Sets `display` to `block`. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css dropdown focus-within menu hover accessibilityCSS Image Gallery
Build a responsive gallery with CSS Grid and consistent aspect ratios.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.gallery { | Targets elements matching: .gallery. |
display:grid; | Sets `display` to `grid`. |
grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); | Sets `grid-template-columns` to `repeat(auto-fit,minmax(160px,1fr))`. |
gap:12px | Sets `gap` to `12px`. |
} | Ends the current rule block. |
.gallery img { | Targets elements matching: .gallery img. |
width:100%; | Sets `width` to `100%`. |
height:140px; | Sets `height` to `140px`. |
object-fit:cover; | Sets `object-fit` to `cover`. |
border-radius:12px | Sets `border-radius` to `12px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css gallery grid responsive images thumbnail gapCSS Image Sprites
Sprites pack many icons into one image to reduce requests (less needed with modern bundling).
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.icon { | Targets elements matching: .icon. |
width:24px; | Sets `width` to `24px`. |
height:24px; | Sets `height` to `24px`. |
background:url(sprite.png) no-repeat | Sets `background` to `url(sprite.png) no-repeat`. |
} | Ends the current rule block. |
.icon.home { | Targets elements matching: .icon.home. |
background-position:0 0 | Sets `background-position` to `0 0`. |
} | Ends the current rule block. |
.icon.user { | Targets elements matching: .icon.user. |
background-position:-24px 0 | Sets `background-position` to `-24px 0`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css sprite background-position icons performance sprite sheetCSS Attribute Selectors
Select by attributes like type, href, or data-* for clean and predictable styling.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
input[type="password"] { | Targets elements matching: input[type="password"]. |
letter-spacing:.25em | Sets `letter-spacing` to `.25em`. |
} | Ends the current rule block. |
a[href^="https://"]::after { | Targets elements matching: a[href^="https://"]::after. |
content:" ↗"; | Sets `content` to `" ↗"`. |
opacity:.7 | Sets `opacity` to `.7`. |
} | Ends the current rule block. |
- 1Target buttons/links/forms precisely without adding extra HTML.
- 2Build reusable component classes instead of styling every tag globally.
- 1Using IDs everywhere (high specificity, hard to override).
- 2Writing overly long selectors that are fragile.
- 1Prefer class selectors for components.
- 2Keep specificity low; override by placing rules later or using a parent class.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
attribute selectors data attributes selectors css formsCSS Forms
Form styling focuses on padding, borders, focus states, and spacing for readability.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
input,select,textarea { | Targets elements matching: input,select,textarea. |
padding:10px 12px; | Sets `padding` to `10px 12px`. |
border-radius:10px; | Sets `border-radius` to `10px`. |
border:1px solid #334155 | Sets `border` to `1px solid #334155`. |
} | Ends the current rule block. |
input:focus-visible { | Targets elements matching: input:focus-visible. |
outline:3px solid #00e5ff; | Sets `outline` to `3px solid #00e5ff`. |
outline-offset:2px | Sets `outline-offset` to `2px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css forms input styling focus form layout accessibilityCSS Counters
Counters generate automatic numbering without editing HTML, useful for steps and headings.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.steps { | Targets elements matching: .steps. |
counter-reset:step | Sets `counter-reset` to `step`. |
} | Ends the current rule block. |
.steps li { | Targets elements matching: .steps li. |
counter-increment:step | Sets `counter-increment` to `step`. |
} | Ends the current rule block. |
.steps li::before { | Targets elements matching: .steps li::before. |
content:counter(step) ". "; | Sets `content` to `counter(step) ". "`. |
font-weight:900 | Sets `font-weight` to `900`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css counters counter-reset counter-increment steps numberingCSS Units
Use px for fixed sizes, rem for scalable typography, and %/vw for responsive layouts.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
:root { | Targets elements matching: :root. |
font-size:16px | Sets `font-size` to `16px`. |
} | Ends the current rule block. |
h1 { | Targets elements matching: h1. |
font-size:2rem | Sets `font-size` to `2rem`. |
} | Ends the current rule block. |
.box { | Targets elements matching: .box. |
width:50vw; | Sets `width` to `50vw`. |
max-width:720px | Sets `max-width` to `720px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css units px rem em vwCSS Inheritance
Some properties inherit (like color/font), others don’t (like margin). Use inherit/initial/unset.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.panel { | Targets elements matching: .panel. |
color:#e2e8f0 | Sets `color` to `#e2e8f0`. |
} | Ends the current rule block. |
.panel a { | Targets elements matching: .panel a. |
color:inherit | Sets `color` to `inherit`. |
} | Ends the current rule block. |
.reset { | Targets elements matching: .reset. |
all:unset | Sets `all` to `unset`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css inheritance inherit initial unset cascadeCSS Specificity
When rules conflict, specificity (and source order) decides which one wins.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
#btn { | Targets elements matching: #btn. |
background:red | Sets `background` to `red`. |
} | Ends the current rule block. |
.btn { | Targets elements matching: .btn. |
background:green | Sets `background` to `green`. |
} | Ends the current rule block. |
- 1Debugging CSS quickly depends on understanding cascade + specificity.
- 2Design systems rely on predictable overrides.
- 1Using `!important` everywhere.
- 2Chasing overrides by making selectors longer and longer.
- 1Use a component root class (ex: `.app`) to scope overrides.
- 2Keep a consistent order: base → components → utilities.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css specificity cascade id vs class important selectorsCSS !important
Use !important only as a last resort (e.g., utility overrides). Prefer better structure.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.text-muted { | Targets elements matching: .text-muted. |
color:#94a3b8 !important | Sets `color` to `#94a3b8 !important`. |
} | Ends the current rule block. |
- 1Debugging CSS quickly depends on understanding cascade + specificity.
- 2Design systems rely on predictable overrides.
- 1Using `!important` as a default (hard to maintain).
- 2Forgetting that `!important` still follows specificity rules among important declarations.
- 3Breaking theming because important overrides tokens.
- 1Use `!important` only for tiny utilities/hotfixes.
- 2Fix the selector or cascade instead of forcing overrides.
- 3Document why it’s needed if you must use it.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css important !important override specificity utilitiesCSS Math Functions
Use calc(), min(), max(), and clamp() to build fluid, responsive values.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.title { | Targets elements matching: .title. |
font-size:clamp(20px,4vw,44px) | Sets `font-size` to `clamp(20px,4vw,44px)`. |
} | Ends the current rule block. |
.card { | Targets elements matching: .card. |
padding:calc(12px + 1vw) | Sets `padding` to `calc(12px + 1vw)`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css calc css clamp min max responsive typography fluid spacingCSS Optimization
Keep CSS fast by reducing unused styles, avoiding expensive selectors, and using modern layout tools.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.btn { | Targets elements matching: .btn. |
... | CSS statement. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css optimization performance critical css reduce unused css best practicesCSS Accessibility
Accessible CSS means readable contrast, visible focus, reduced motion options, and clear states.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
@media (prefers-reduced-motion: reduce) { | Targets elements matching: @media (prefers-reduced-motion: reduce). |
* { | Targets elements matching: *. |
animation:none !important; | Sets `animation` to `none !important`. |
transition:none !important | Sets `transition` to `none !important`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css accessibility focus visible contrast reduced motion a11yCSS Website Layout
Modern layouts use Grid for overall page structure and Flexbox for component alignment.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.layout { | Targets elements matching: .layout. |
display:grid; | Sets `display` to `grid`. |
grid-template-columns:260px 1fr; | Sets `grid-template-columns` to `260px 1fr`. |
min-height:100vh | Sets `min-height` to `100vh`. |
} | Ends the current rule block. |
@media(max-width:900px) { | Targets elements matching: @media(max-width:900px). |
.layout { | Targets elements matching: .layout. |
grid-template-columns:1fr | Sets `grid-template-columns` to `1fr`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css layout grid layout flexbox layout website layout responsive layoutCSS Rounded Corners
Use border-radius for rounded shapes; large radius creates pills and circles.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.card { | Targets elements matching: .card. |
border-radius:16px | Sets `border-radius` to `16px`. |
} | Ends the current rule block. |
.pill { | Targets elements matching: .pill. |
border-radius:999px | Sets `border-radius` to `999px`. |
} | Ends the current rule block. |
.avatar { | Targets elements matching: .avatar. |
border-radius:50% | Sets `border-radius` to `50%`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
border-radius rounded corners pill circle uiCSS Border Images
border-image lets you use an image (or gradient) as the border of an element.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.box { | Targets elements matching: .box. |
border:10px solid transparent; | Sets `border` to `10px solid transparent`. |
border-image:linear-gradient(90deg,#00e5ff,#7c4dff) 1; | Sets `border-image` to `linear-gradient(90deg,#00e5ff,#7c4dff) 1`. |
} | Ends the current rule block. |
- 1Consistent spacing and borders make layouts feel clean and professional.
- 2Focus outlines improve keyboard usability.
- 1Forgetting `box-sizing: border-box` and getting unexpected widths.
- 2Using large fixed padding on small screens.
- 1Set `*,*::before,*::after{box-sizing:border-box}` early.
- 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
border-image css borders decorative border slice repeatCSS Backgrounds (Advanced)
Backgrounds can be solid, gradients, or images, and you control size, repeat, and position.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.hero { | Targets elements matching: .hero. |
background:linear-gradient(135deg,#1d4ed8,#0ea5e9); | Sets `background` to `linear-gradient(135deg,#1d4ed8,#0ea5e9)`. |
background-size:cover; | Sets `background-size` to `cover`. |
} | Ends the current rule block. |
- 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
- 2Gradients and shadows can replace image assets for simple UI depth.
- 1Low contrast text (hard to read).
- 2Overusing heavy shadows and making UI look blurry.
- 1Aim for readable contrast; test quickly by lowering screen brightness.
- 2Prefer soft, low-opacity shadows and avoid stacking many effects.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css background background image background size background position coverCSS Colors (Advanced)
CSS supports named colors, hex, rgb/rgba, hsl/hsla, and modern color functions.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.badge { | Targets elements matching: .badge. |
color:#0f172a; | Sets `color` to `#0f172a`. |
background:#ffd54f | Sets `background` to `#ffd54f`. |
} | Ends the current rule block. |
.overlay { | Targets elements matching: .overlay. |
background:rgba(2,6,23,.6) | Sets `background` to `rgba(2,6,23,.6)`. |
} | Ends the current rule block. |
.brand { | Targets elements matching: .brand. |
color:hsl(190 95% 45%) | Sets `color` to `hsl(190 95% 45%)`. |
} | Ends the current rule block. |
- 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
- 2Gradients and shadows can replace image assets for simple UI depth.
- 1Low contrast text (hard to read).
- 2Overusing heavy shadows and making UI look blurry.
- 1Aim for readable contrast; test quickly by lowering screen brightness.
- 2Prefer soft, low-opacity shadows and avoid stacking many effects.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css colors hex color rgb hsl rgbaCSS Gradients
Gradients create smooth transitions between colors without images.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.hero { | Targets elements matching: .hero. |
background:linear-gradient(135deg,#00e5ff,#7c4dff) | Sets `background` to `linear-gradient(135deg,#00e5ff,#7c4dff)`. |
} | Ends the current rule block. |
.badge { | Targets elements matching: .badge. |
background:radial-gradient(circle,#ffd54f,#ff4081) | Sets `background` to `radial-gradient(circle,#ffd54f,#ff4081)`. |
} | Ends the current rule block. |
- 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
- 2Gradients and shadows can replace image assets for simple UI depth.
- 1Low contrast text (hard to read).
- 2Overusing heavy shadows and making UI look blurry.
- 1Aim for readable contrast; test quickly by lowering screen brightness.
- 2Prefer soft, low-opacity shadows and avoid stacking many effects.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css gradients linear-gradient radial-gradient background designCSS Shadows
box-shadow adds depth to components; text-shadow can improve contrast carefully.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.card { | Targets elements matching: .card. |
box-shadow:0 10px 30px rgba(0,0,0,.35) | Sets `box-shadow` to `0 10px 30px rgba(0,0,0,.35)`. |
} | Ends the current rule block. |
.title { | Targets elements matching: .title. |
text-shadow:0 2px 12px rgba(0,0,0,.35) | Sets `text-shadow` to `0 2px 12px rgba(0,0,0,.35)`. |
} | Ends the current rule block. |
- 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
- 2Gradients and shadows can replace image assets for simple UI depth.
- 1Low contrast text (hard to read).
- 2Overusing heavy shadows and making UI look blurry.
- 1Aim for readable contrast; test quickly by lowering screen brightness.
- 2Prefer soft, low-opacity shadows and avoid stacking many effects.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
box-shadow text-shadow elevation depth uiCSS Text Effects
Use text-shadow, strokes, and clipping with care so text stays readable.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.glow { | Targets elements matching: .glow. |
text-shadow:0 0 18px rgba(0,229,255,.55) | Sets `text-shadow` to `0 0 18px rgba(0,229,255,.55)`. |
} | Ends the current rule block. |
.stroke { | Targets elements matching: .stroke. |
-webkit-text-stroke:1px #00e5ff; | Sets `-webkit-text-stroke` to `1px #00e5ff`. |
color:transparent | Sets `color` to `transparent`. |
} | Ends the current rule block. |
- 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
- 2Gradients and shadows can replace image assets for simple UI depth.
- 1Low contrast text (hard to read).
- 2Overusing heavy shadows and making UI look blurry.
- 1Aim for readable contrast; test quickly by lowering screen brightness.
- 2Prefer soft, low-opacity shadows and avoid stacking many effects.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
text effects text-shadow text stroke gradient text typographyCSS Custom Fonts
Load fonts using @font-face or providers. Always keep fallbacks for reliability.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
@font-face { | Targets elements matching: @font-face. |
font-family:MyFont; | Sets `font-family` to `MyFont`. |
src:url(MyFont.woff2) format("woff2"); | Sets `src` to `url(MyFont.woff2) format("woff2")`. |
} | Ends the current rule block. |
body { | Targets elements matching: body. |
font-family:MyFont,system-ui,sans-serif | Sets `font-family` to `MyFont,system-ui,sans-serif`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
custom fonts @font-face web fonts typography fallback fontsCSS 2D Transforms
Transform elements with translate/rotate/scale without affecting layout.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.btn:hover { | Targets elements matching: .btn:hover. |
transform:translateY(-2px) scale(1.02) | Sets `transform` to `translateY(-2px) scale(1.02)`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
2d transforms translate rotate scale transformCSS 3D Transforms
3D transforms add perspective and depth (use sparingly).
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.card { | Targets elements matching: .card. |
transform:perspective(900px) rotateY(12deg); | Sets `transform` to `perspective(900px) rotateY(12deg)`. |
transform-style:preserve-3d | Sets `transform-style` to `preserve-3d`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
3d transforms perspective rotateY transform-style 3dCSS Transitions
Transitions animate property changes smoothly (hover, focus, state classes).
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.btn { | Targets elements matching: .btn. |
transition:transform .2s ease, filter .2s ease | Sets `transition` to `transform .2s ease, filter .2s ease`. |
} | Ends the current rule block. |
.btn:hover { | Targets elements matching: .btn:hover. |
transform:translateY(-2px); | Sets `transform` to `translateY(-2px)`. |
filter:brightness(1.05) | Sets `filter` to `brightness(1.05)`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css transitions transition property ease hover animation uiCSS Animations
Animations use @keyframes for repeated motion; respect reduced-motion preferences.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
@keyframes pulse { | Targets elements matching: @keyframes pulse. |
0% { | Targets elements matching: 0%. |
transform:scale(1) | Sets `transform` to `scale(1)`. |
} | Ends the current rule block. |
50% { | Targets elements matching: 50%. |
transform:scale(1.03) | Sets `transform` to `scale(1.03)`. |
} | Ends the current rule block. |
100% { | Targets elements matching: 100%. |
transform:scale(1) | Sets `transform` to `scale(1)`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
.pulse { | Targets elements matching: .pulse. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css animations @keyframes animation motion prefers-reduced-motionCSS Tooltips
Tooltips can be built with pseudo-elements and appear on hover/focus.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.tip { | Targets elements matching: .tip. |
position:relative | Sets `position` to `relative`. |
} | Ends the current rule block. |
.tip:hover::after,.tip:focus-visible::after { | Targets elements matching: .tip:hover::after,.tip:focus-visible::after. |
content:attr(data-tip); | Sets `content` to `attr(data-tip)`. |
position:absolute; | Sets `position` to `absolute`. |
left:0; | Sets `left` to `0`. |
top:110%; | Sets `top` to `110%`. |
padding:6px 8px; | Sets `padding` to `6px 8px`. |
border-radius:8px; | Sets `border-radius` to `8px`. |
background:#111827; | Sets `background` to `#111827`. |
color:#fff; | Sets `color` to `#fff`. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css tooltip pseudo element hover focus uiCSS Image Styling
Images often need border-radius, shadows, and object-fit to look consistent.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
img.thumb { | Targets elements matching: img.thumb. |
width:100%; | Sets `width` to `100%`. |
height:180px; | Sets `height` to `180px`. |
object-fit:cover; | Sets `object-fit` to `cover`. |
border-radius:14px; | Sets `border-radius` to `14px`. |
box-shadow:0 10px 25px rgba(0,0,0,.25) | Sets `box-shadow` to `0 10px 25px rgba(0,0,0,.25)`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
image styling border-radius object-fit responsive image cssCSS Image Modal
A modal is an overlay. Use fixed positioning and a centered panel.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.overlay { | Targets elements matching: .overlay. |
position:fixed; | Sets `position` to `fixed`. |
inset:0; | Sets `inset` to `0`. |
background:rgba(2,6,23,.7); | Sets `background` to `rgba(2,6,23,.7)`. |
display:grid; | Sets `display` to `grid`. |
place-items:center | Sets `place-items` to `center`. |
} | Ends the current rule block. |
.modal { | Targets elements matching: .modal. |
background:#0f172a; | Sets `background` to `#0f172a`. |
padding:16px; | Sets `padding` to `16px`. |
border-radius:14px; | Sets `border-radius` to `14px`. |
max-width:92vw | Sets `max-width` to `92vw`. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
image modal css modal overlay z-index dialogCSS Image Centering
Center images with display:block + margin:auto or via flex/grid containers.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
img.center { | Targets elements matching: img.center. |
display:block; | Sets `display` to `block`. |
margin:0 auto | Sets `margin` to `0 auto`. |
} | Ends the current rule block. |
.wrap { | Targets elements matching: .wrap. |
display:grid; | Sets `display` to `grid`. |
place-items:center | Sets `place-items` to `center`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
center image margin auto flex center grid center cssCSS Image Filters
Filters adjust visuals (blur, grayscale, contrast). Use lightly to avoid readability issues.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
img.fx { | Targets elements matching: img.fx. |
filter:grayscale(1) contrast(1.1) | Sets `filter` to `grayscale(1) contrast(1.1)`. |
} | Ends the current rule block. |
img.fx:hover { | Targets elements matching: img.fx:hover. |
filter:none | Sets `filter` to `none`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css filter grayscale blur brightness image effectsCSS Image Shapes
Use border-radius and clip-path to create circles and custom shapes.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
img.circle { | Targets elements matching: img.circle. |
border-radius:50% | Sets `border-radius` to `50%`. |
} | Ends the current rule block. |
.cut { | Targets elements matching: .cut. |
clip-path:polygon(0 0,100% 0,85% 100%,0 100%) | Sets `clip-path` to `polygon(0 0,100% 0,85% 100%,0 100%)`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
clip-path image shapes circle image polygon cssCSS object-fit
object-fit controls how replaced content (images/videos) fill their box.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
img { | Targets elements matching: img. |
width:260px; | Sets `width` to `260px`. |
height:160px; | Sets `height` to `160px`. |
object-fit:cover | Sets `object-fit` to `cover`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
object-fit cover contain responsive images croppingCSS object-position
object-position chooses which part of an image stays visible when cropping.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
img { | Targets elements matching: img. |
object-fit:cover; | Sets `object-fit` to `cover`. |
object-position:top center | Sets `object-position` to `top center`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
object-position image crop top center coverCSS Masking
Masking hides parts of an element using an image/gradient (browser support varies).
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.fade { | Targets elements matching: .fade. |
-webkit-mask-image:linear-gradient(#000,transparent); | Sets `-webkit-mask-image` to `linear-gradient(#000,transparent)`. |
mask-image:linear-gradient(#000,transparent); | Sets `mask-image` to `linear-gradient(#000,transparent)`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css masking mask-image gradient mask clip effectsCSS Buttons
Buttons need good padding, hover/focus styles, and consistent colors.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.btn { | Targets elements matching: .btn. |
padding:10px 14px; | Sets `padding` to `10px 14px`. |
border-radius:12px; | Sets `border-radius` to `12px`. |
border:1px solid #334155; | Sets `border` to `1px solid #334155`. |
background:#111827; | Sets `background` to `#111827`. |
color:#fff | Sets `color` to `#fff`. |
} | Ends the current rule block. |
.btn:hover { | Targets elements matching: .btn:hover. |
filter:brightness(1.05) | Sets `filter` to `brightness(1.05)`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css button button style hover focus uiCSS Pagination
Pagination is a row of links; style active and hover states clearly.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.pager { | Targets elements matching: .pager. |
display:flex; | Sets `display` to `flex`. |
gap:8px | Sets `gap` to `8px`. |
} | Ends the current rule block. |
.pager a { | Targets elements matching: .pager a. |
padding:8px 10px; | Sets `padding` to `8px 10px`. |
border:1px solid #334155; | Sets `border` to `1px solid #334155`. |
border-radius:10px; | Sets `border-radius` to `10px`. |
text-decoration:none | Sets `text-decoration` to `none`. |
} | Ends the current rule block. |
.pager a.active { | Targets elements matching: .pager a.active. |
background:#00e5ff; | Sets `background` to `#00e5ff`. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css pagination active page nav links uiCSS Multiple Columns
Multi-column layout splits text into columns (like a newspaper).
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.cols { | Targets elements matching: .cols. |
column-count:3; | Sets `column-count` to `3`. |
column-gap:18px | Sets `column-gap` to `18px`. |
} | Ends the current rule block. |
@media(max-width:900px) { | Targets elements matching: @media(max-width:900px). |
.cols { | Targets elements matching: .cols. |
column-count:1 | Sets `column-count` to `1`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css columns multi column column-count column-gap layoutCSS User Interface
UI properties include cursor, resize, appearance, and accent-color for controls.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
:root { | Targets elements matching: :root. |
accent-color:#00e5ff | Sets `accent-color` to `#00e5ff`. |
} | Ends the current rule block. |
textarea { | Targets elements matching: textarea. |
resize:vertical | Sets `resize` to `vertical`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css ui accent-color appearance resize cursorCSS Variables
Custom properties (variables) let you reuse values and theme a site quickly.
:root { --accent: #00e5ff; }
.btn { background: var(--accent); }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
:root { | Targets elements matching: :root. |
--brand:#00e5ff | Sets `--brand` to `#00e5ff`. |
} | Ends the current rule block. |
.btn { | Targets elements matching: .btn. |
background:var(--brand); | Sets `background` to `var(--brand)`. |
color:#001018 | Sets `color` to `#001018`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css variables custom properties :root theming design tokensCSS @property
@property registers typed custom properties so transitions/animations behave correctly.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
@property --a { | Targets elements matching: @property --a. |
syntax:"<angle>"; | Sets `syntax` to `"<angle>"`. |
inherits:true; | Sets `inherits` to `true`. |
initial-value:0deg; | Sets `initial-value` to `0deg`. |
} | Ends the current rule block. |
.ring { | Targets elements matching: .ring. |
background:conic-gradient(from var(--a),#00e5ff,#7c4dff); | Sets `background` to `conic-gradient(from var(--a),#00e5ff,#7c4dff)`. |
transition:--a .6s ease | Sets `transition` to `--a .6s ease`. |
} | Ends the current rule block. |
.ring:hover { | Targets elements matching: .ring:hover. |
--a:180deg | Sets `--a` to `180deg`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css @property custom properties typed variables animation houdiniCSS Box Sizing
box-sizing: border-box makes layouts simpler because padding/border count inside width.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
*,*::before,*::after { | Targets elements matching: *,*::before,*::after. |
box-sizing:border-box | Sets `box-sizing` to `border-box`. |
} | Ends the current rule block. |
- 1Consistent spacing and borders make layouts feel clean and professional.
- 2Focus outlines improve keyboard usability.
- 1Forgetting `box-sizing: border-box` and getting unexpected widths.
- 2Using large fixed padding on small screens.
- 1Set `*,*::before,*::after{box-sizing:border-box}` early.
- 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
box-sizing border-box layout box model resetCSS Media Queries
Media queries adapt styles based on viewport size or user preferences.
@media (max-width: 600px) {
.layout { grid-template-columns: 1fr; }
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
@media (max-width:700px) { | Targets elements matching: @media (max-width:700px). |
.sidebar { | Targets elements matching: .sidebar. |
display:none | Sets `display` to `none`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
- 1Make layouts adapt to phones, tablets, and desktops.
- 2Respect user preferences like reduced motion and dark mode.
- 1Choosing breakpoints by device names (instead of where layout breaks).
- 2Animating layout properties causing jank on mobile.
- 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
- 2Add `prefers-reduced-motion` fallback for animations.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
media queries responsive breakpoints prefers-color-scheme cssFlexbox Intro
Flexbox is perfect for one-direction layouts (rows OR columns) with easy alignment.
.row { display: flex; gap: 12px; }
.item { flex: 1; }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.row { | Targets elements matching: .row. |
display:flex; | Sets `display` to `flex`. |
gap:10px | Sets `gap` to `10px`. |
} | Ends the current rule block. |
.row > * { | Targets elements matching: .row > *. |
flex:1 | Sets `flex` to `1`. |
} | Ends the current rule block. |
- 1Consistent spacing and borders make layouts feel clean and professional.
- 2Focus outlines improve keyboard usability.
- 1Forgetting `box-sizing: border-box` and getting unexpected widths.
- 2Using large fixed padding on small screens.
- 1Set `*,*::before,*::after{box-sizing:border-box}` early.
- 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
flexbox display flex alignment layout css flexFlex Container
Container properties like justify-content and align-items control how items align.
.row { display: flex; gap: 12px; }
.item { flex: 1; }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.row { | Targets elements matching: .row. |
display:flex; | Sets `display` to `flex`. |
justify-content:space-between; | Sets `justify-content` to `space-between`. |
align-items:center; | Sets `align-items` to `center`. |
gap:12px; | Sets `gap` to `12px`. |
flex-wrap:wrap | Sets `flex-wrap` to `wrap`. |
} | Ends the current rule block. |
- 1Navbars, toolbars, chip rows, and card footers are usually Flexbox.
- 2Centering and spacing items becomes simple.
- 1Forgetting `flex-wrap` and breaking mobile layout.
- 2Mixing `gap` and margins randomly (inconsistent).
- 1Use `gap` for spacing between flex items.
- 2Use `flex: 1 1 ...` for responsive cards/chips.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
justify-content align-items flex container gap flex-wrapFlex Items
Item properties like flex, align-self, and order control a single element’s behavior.
.row { display: flex; gap: 12px; }
.item { flex: 1; }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.item { | Targets elements matching: .item. |
flex:1 1 180px | Sets `flex` to `1 1 180px`. |
} | Ends the current rule block. |
.item.featured { | Targets elements matching: .item.featured. |
order:-1; | Sets `order` to `-1`. |
align-self:stretch | Sets `align-self` to `stretch`. |
} | Ends the current rule block. |
- 1Navbars, toolbars, chip rows, and card footers are usually Flexbox.
- 2Centering and spacing items becomes simple.
- 1Forgetting `flex-wrap` and breaking mobile layout.
- 2Mixing `gap` and margins randomly (inconsistent).
- 1Use `gap` for spacing between flex items.
- 2Use `flex: 1 1 ...` for responsive cards/chips.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
flex flex-basis flex-grow align-self orderFlex Responsive
Make flex layouts responsive with wrapping and media queries.
.row { display: flex; gap: 12px; }
.item { flex: 1; }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.row { | Targets elements matching: .row. |
display:flex; | Sets `display` to `flex`. |
gap:12px; | Sets `gap` to `12px`. |
flex-wrap:wrap | Sets `flex-wrap` to `wrap`. |
} | Ends the current rule block. |
@media(max-width:700px) { | Targets elements matching: @media(max-width:700px). |
.row { | Targets elements matching: .row. |
flex-direction:column | Sets `flex-direction` to `column`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
- 1Navbars, toolbars, chip rows, and card footers are usually Flexbox.
- 2Centering and spacing items becomes simple.
- 1Forgetting `flex-wrap` and breaking mobile layout.
- 2Mixing `gap` and margins randomly (inconsistent).
- 1Use `gap` for spacing between flex items.
- 2Use `flex: 1 1 ...` for responsive cards/chips.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
responsive flexbox flex-wrap breakpoints stack on mobile cssGrid Intro
CSS Grid is ideal for 2D layouts: rows and columns together.
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cell { ... }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.grid { | Targets elements matching: .grid. |
display:grid; | Sets `display` to `grid`. |
grid-template-columns:repeat(3,1fr); | Sets `grid-template-columns` to `repeat(3,1fr)`. |
gap:12px | Sets `gap` to `12px`. |
} | Ends the current rule block. |
- 1Page layouts, galleries, dashboards, and responsive cards use Grid.
- 2Two-dimensional alignment is much easier than with floats.
- 1Hardcoding column counts instead of using responsive tracks.
- 2Forgetting `minmax(0,1fr)` and causing overflow.
- 1Use `repeat(auto-fit, minmax(160px, 1fr))` for responsive grids.
- 2Use `grid-template-areas` for readable page layouts.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css grid grid layout rows and columns layout responsiveGrid Container
Define columns/rows with grid-template and control spacing using gap.
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cell { ... }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.grid { | Targets elements matching: .grid. |
display:grid; | Sets `display` to `grid`. |
grid-template-columns:240px 1fr; | Sets `grid-template-columns` to `240px 1fr`. |
grid-template-rows:auto 1fr; | Sets `grid-template-rows` to `auto 1fr`. |
gap:12px | Sets `gap` to `12px`. |
} | Ends the current rule block. |
- 1Page layouts, galleries, dashboards, and responsive cards use Grid.
- 2Two-dimensional alignment is much easier than with floats.
- 1Hardcoding column counts instead of using responsive tracks.
- 2Forgetting `minmax(0,1fr)` and causing overflow.
- 1Use `repeat(auto-fit, minmax(160px, 1fr))` for responsive grids.
- 2Use `grid-template-areas` for readable page layouts.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
grid-template-columns grid-template-rows gap grid auto flow grid containerGrid Items
Place items using grid-column/grid-row or the shorthand grid-area.
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cell { ... }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.item.hero { | Targets elements matching: .item.hero. |
grid-column:1 / -1 | Sets `grid-column` to `1 / -1`. |
} | Ends the current rule block. |
.item.sidebar { | Targets elements matching: .item.sidebar. |
grid-row:2 / 4 | Sets `grid-row` to `2 / 4`. |
} | Ends the current rule block. |
- 1Page layouts, galleries, dashboards, and responsive cards use Grid.
- 2Two-dimensional alignment is much easier than with floats.
- 1Hardcoding column counts instead of using responsive tracks.
- 2Forgetting `minmax(0,1fr)` and causing overflow.
- 1Use `repeat(auto-fit, minmax(160px, 1fr))` for responsive grids.
- 2Use `grid-template-areas` for readable page layouts.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
grid-column grid-row grid-area place-items gridGrid 12-column Layout
A 12-column grid is a common responsive system for dashboards and websites.
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cell { ... }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.grid12 { | Targets elements matching: .grid12. |
display:grid; | Sets `display` to `grid`. |
grid-template-columns:repeat(12,1fr); | Sets `grid-template-columns` to `repeat(12,1fr)`. |
gap:12px | Sets `gap` to `12px`. |
} | Ends the current rule block. |
.span6 { | Targets elements matching: .span6. |
grid-column:span 6 | Sets `grid-column` to `span 6`. |
} | Ends the current rule block. |
@media(max-width:800px) { | Targets elements matching: @media(max-width:800px). |
.span6 { | Targets elements matching: .span6. |
grid-column:span 12 | Sets `grid-column` to `span 12`. |
} | Ends the current rule block. |
- 1Page layouts, galleries, dashboards, and responsive cards use Grid.
- 2Two-dimensional alignment is much easier than with floats.
- 1Hardcoding column counts instead of using responsive tracks.
- 2Forgetting `minmax(0,1fr)` and causing overflow.
- 1Use `repeat(auto-fit, minmax(160px, 1fr))` for responsive grids.
- 2Use `grid-template-areas` for readable page layouts.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
12 column grid grid system responsive grid layout cssCSS @supports
Feature queries let you apply styles only if the browser supports a property/value.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
@supports (backdrop-filter: blur(10px)) { | Targets elements matching: @supports (backdrop-filter: blur(10px)). |
.glass { | Targets elements matching: .glass. |
backdrop-filter:blur(10px) | Sets `backdrop-filter` to `blur(10px)`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
@supports feature queries progressive enhancement fallback cssRWD Intro
Responsive Web Design (RWD) makes layouts adapt to different screen sizes.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.grid { | Targets elements matching: .grid. |
display:grid; | Sets `display` to `grid`. |
grid-template-columns:1fr | Sets `grid-template-columns` to `1fr`. |
} | Ends the current rule block. |
@media(min-width:900px) { | Targets elements matching: @media(min-width:900px). |
.grid { | Targets elements matching: .grid. |
grid-template-columns:260px 1fr | Sets `grid-template-columns` to `260px 1fr`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
- 1Make layouts adapt to phones, tablets, and desktops.
- 2Respect user preferences like reduced motion and dark mode.
- 1Choosing breakpoints by device names (instead of where layout breaks).
- 2Animating layout properties causing jank on mobile.
- 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
- 2Add `prefers-reduced-motion` fallback for animations.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
responsive web design rwd mobile first breakpoints cssRWD Viewport
The viewport meta tag is required so mobile browsers size the page correctly.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | CSS statement. |
- 1Make layouts adapt to phones, tablets, and desktops.
- 2Respect user preferences like reduced motion and dark mode.
- 1Choosing breakpoints by device names (instead of where layout breaks).
- 2Animating layout properties causing jank on mobile.
- 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
- 2Add `prefers-reduced-motion` fallback for animations.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
viewport meta mobile viewport responsive device width html headRWD Grid View
Use Grid for page structure, then adjust columns at breakpoints.
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cell { ... }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.grid { | Targets elements matching: .grid. |
display:grid; | Sets `display` to `grid`. |
grid-template-columns:repeat(12,1fr); | Sets `grid-template-columns` to `repeat(12,1fr)`. |
gap:12px | Sets `gap` to `12px`. |
} | Ends the current rule block. |
.main { | Targets elements matching: .main. |
grid-column:1 / -1 | Sets `grid-column` to `1 / -1`. |
} | Ends the current rule block. |
@media(min-width:900px) { | Targets elements matching: @media(min-width:900px). |
.main { | Targets elements matching: .main. |
grid-column:4 / -1 | Sets `grid-column` to `4 / -1`. |
} | Ends the current rule block. |
- 1Page layouts, galleries, dashboards, and responsive cards use Grid.
- 2Two-dimensional alignment is much easier than with floats.
- 1Hardcoding column counts instead of using responsive tracks.
- 2Forgetting `minmax(0,1fr)` and causing overflow.
- 1Use `repeat(auto-fit, minmax(160px, 1fr))` for responsive grids.
- 2Use `grid-template-areas` for readable page layouts.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
responsive grid css grid breakpoints layout columnsRWD Media Queries
Breakpoints are simply media queries where your layout needs to change.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
@media(max-width:640px) { | Targets elements matching: @media(max-width:640px). |
.nav { | Targets elements matching: .nav. |
display:none | Sets `display` to `none`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
- 1Make layouts adapt to phones, tablets, and desktops.
- 2Respect user preferences like reduced motion and dark mode.
- 1Choosing breakpoints by device names (instead of where layout breaks).
- 2Animating layout properties causing jank on mobile.
- 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
- 2Add `prefers-reduced-motion` fallback for animations.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
responsive media queries breakpoints mobile first css layoutRWD Images
Make images scale with the container to prevent horizontal scroll.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
img { | Targets elements matching: img. |
max-width:100%; | Sets `max-width` to `100%`. |
height:auto; | Sets `height` to `auto`. |
display:block | Sets `display` to `block`. |
} | Ends the current rule block. |
- 1Make layouts adapt to phones, tablets, and desktops.
- 2Respect user preferences like reduced motion and dark mode.
- 1Choosing breakpoints by device names (instead of where layout breaks).
- 2Animating layout properties causing jank on mobile.
- 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
- 2Add `prefers-reduced-motion` fallback for animations.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
responsive images max-width height auto css imgRWD Videos
Use an aspect-ratio wrapper for responsive iframes/videos.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.ratio { | Targets elements matching: .ratio. |
aspect-ratio:16/9 | Sets `aspect-ratio` to `16/9`. |
} | Ends the current rule block. |
.ratio iframe { | Targets elements matching: .ratio iframe. |
width:100%; | Sets `width` to `100%`. |
height:100%; | Sets `height` to `100%`. |
border:0 | Sets `border` to `0`. |
} | Ends the current rule block. |
- 1Make layouts adapt to phones, tablets, and desktops.
- 2Respect user preferences like reduced motion and dark mode.
- 1Choosing breakpoints by device names (instead of where layout breaks).
- 2Animating layout properties causing jank on mobile.
- 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
- 2Add `prefers-reduced-motion` fallback for animations.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
responsive video aspect-ratio iframe css embedRWD Frameworks
Frameworks (Bootstrap/Tailwind) speed up responsive UI. Learn core CSS first.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|
- 1Make layouts adapt to phones, tablets, and desktops.
- 2Respect user preferences like reduced motion and dark mode.
- 1Choosing breakpoints by device names (instead of where layout breaks).
- 2Animating layout properties causing jank on mobile.
- 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
- 2Add `prefers-reduced-motion` fallback for animations.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
bootstrap tailwind responsive framework css utility grid systemRWD Templates
Start from a layout template, then customize spacing, typography, and colors.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.page { | Targets elements matching: .page. |
min-height:100vh; | Sets `min-height` to `100vh`. |
display:grid; | Sets `display` to `grid`. |
grid-template-rows:auto 1fr auto | Sets `grid-template-rows` to `auto 1fr auto`. |
} | Ends the current rule block. |
- 1Make layouts adapt to phones, tablets, and desktops.
- 2Respect user preferences like reduced motion and dark mode.
- 1Choosing breakpoints by device names (instead of where layout breaks).
- 2Animating layout properties causing jank on mobile.
- 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
- 2Add `prefers-reduced-motion` fallback for animations.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
responsive templates layout template starter css websiteSASS Tutorial
Sass adds variables, nesting, and functions. It compiles to normal CSS.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
$brand: #00e5ff; | Sets `$brand` to `#00e5ff`. |
.btn { | Targets elements matching: .btn. |
background:$brand; | Sets `background` to `$brand`. |
&:hover { | Targets elements matching: &:hover. |
filter:brightness(1.05) | Sets `filter` to `brightness(1.05)`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
sass scss variables nesting css preprocessorCSS Templates
Templates are ready-made layouts. Use them to learn structure and spacing patterns.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.layout { | Targets elements matching: .layout. |
display:grid; | Sets `display` to `grid`. |
grid-template-areas:"nav nav" "side main"; | Sets `grid-template-areas` to `"nav nav" "side main"`. |
gap:12px | Sets `gap` to `12px`. |
} | Ends the current rule block. |
.nav { | Targets elements matching: .nav. |
grid-area:nav | Sets `grid-area` to `nav`. |
} | Ends the current rule block. |
.side { | Targets elements matching: .side. |
grid-area:side | Sets `grid-area` to `side`. |
} | Ends the current rule block. |
.main { | Targets elements matching: .main. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css templates layout starter template responsive uiCSS Examples
Short examples help you learn one concept at a time.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.pill { | Targets elements matching: .pill. |
border:1px solid #334155; | Sets `border` to `1px solid #334155`. |
padding:6px 10px; | Sets `padding` to `6px 10px`. |
border-radius:999px | Sets `border-radius` to `999px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css examples snippets learn by example css code practiceCSS Editor
Use a live editor to test CSS quickly (this page already includes a live CSS lab).
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.box { | Targets elements matching: .box. |
padding:16px; | Sets `padding` to `16px`. |
border:1px dashed #00e5ff | Sets `border` to `1px dashed #00e5ff`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css editor live preview playground try css sandboxCSS Snippets
Snippets are reusable patterns like cards, buttons, gradients, and layouts.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.card { | Targets elements matching: .card. |
background:#0f172a; | Sets `background` to `#0f172a`. |
border:1px solid rgba(148,163,184,.25); | Sets `border` to `1px solid rgba(148,163,184,.25)`. |
border-radius:14px; | Sets `border-radius` to `14px`. |
padding:18px | Sets `padding` to `18px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css snippets ui patterns reusable css components designCSS Quiz
Quick quiz: test concepts like selectors, box model, and specificity.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css quiz css questions practice learn css mcqCSS Exercises
Exercises help you build muscle memory by writing CSS from scratch.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.card { | Targets elements matching: .card. |
padding:16px; | Sets `padding` to `16px`. |
border-radius:14px; | Sets `border-radius` to `14px`. |
border:1px solid #334155 | Sets `border` to `1px solid #334155`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css exercises practice css learn css challenges trainingCSS Code Challenges
Challenges combine multiple concepts (layout + typography + states).
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.nav { | Targets elements matching: .nav. |
display:flex; | Sets `display` to `flex`. |
justify-content:space-between; | Sets `justify-content` to `space-between`. |
align-items:center | Sets `align-items` to `center`. |
} | Ends the current rule block. |
@media(max-width:640px) { | Targets elements matching: @media(max-width:640px). |
.nav { | Targets elements matching: .nav. |
flex-direction:column; | Sets `flex-direction` to `column`. |
align-items:stretch | Sets `align-items` to `stretch`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css challenges projects practice ui layoutCSS Website
Build a small website to apply everything: layout, components, responsiveness, and accessibility.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.page { | Targets elements matching: .page. |
min-height:100vh; | Sets `min-height` to `100vh`. |
display:grid; | Sets `display` to `grid`. |
grid-template-rows:auto 1fr auto | Sets `grid-template-rows` to `auto 1fr auto`. |
} | Ends the current rule block. |
header,footer { | Targets elements matching: header,footer. |
padding:16px | Sets `padding` to `16px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
build website css project responsive website portfolio layoutCSS Syllabus
A syllabus is a checklist of topics. Use it to track learning progress.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css syllabus css roadmap learning path topics planCSS Study Plan
A simple plan: learn basics → build components → learn layout → ship a mini project.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
Week 1: selectors + box model | Sets `Week 1` to `selectors + box model`. |
Week 2: typography + components | Sets `Week 2` to `typography + components`. |
Week 3: flexbox + grid | Sets `Week 3` to `flexbox + grid`. |
Week 4: responsive + a11y + project | Sets `Week 4` to `responsive + a11y + project`. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css study plan roadmap learn css fast practice projectsCSS Interview Prep
Common interview topics: specificity, box model, layout, and responsive strategies.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.center { | Targets elements matching: .center. |
display:grid; | Sets `display` to `grid`. |
place-items:center; | Sets `place-items` to `center`. |
min-height:100vh | Sets `min-height` to `100vh`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css interview frontend interview css questions specificity box modelCSS Bootcamp
Bootcamp mode: build 10 UI components and 3 full layouts with reviews and refactors.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
Day 1: Buttons + Inputs | Sets `Day 1` to `Buttons + Inputs`. |
Day 2: Cards + Modals | Sets `Day 2` to `Cards + Modals`. |
Day 3: Navbar + Sidebar | Sets `Day 3` to `Navbar + Sidebar`. |
Day 4: Grid layout | Sets `Day 4` to `Grid layout`. |
Day 5: Responsive + A11y | Sets `Day 5` to `Responsive + A11y`. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css bootcamp intensive projects components practiceCSS Certificate
A certificate typically requires a final project and a knowledge test.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css certificate css certification frontend project examCSS Reference
A quick reference of properties, selectors, and patterns you use daily.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
display: flex | grid | block | Sets `display` to `flex | grid | block`. |
position: relative | absolute | fixed | sticky | Sets `position` to `relative | absolute | fixed | sticky`. |
box-sizing: border-box | Sets `box-sizing` to `border-box`. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css reference properties selectors cheatsheet css docsCSS Selectors (References)
Selectors target elements (by tag, class, id, attributes, states) so you can style them.
.btn { ... }
#hero { ... }
input[type="email"] { ... }
.btn:hover { ... }
.btn::before { ... }
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
button.primary { | Targets elements matching: button.primary. |
background:#0ea5e9; | Sets `background` to `#0ea5e9`. |
color:#fff | Sets `color` to `#fff`. |
} | Ends the current rule block. |
#hero { | Targets elements matching: #hero. |
padding:24px | Sets `padding` to `24px`. |
} | Ends the current rule block. |
input[type="email"] { | Targets elements matching: input[type="email"]. |
border:1px solid #94a3b8 | Sets `border` to `1px solid #94a3b8`. |
} | Ends the current rule block. |
- 1Target buttons/links/forms precisely without adding extra HTML.
- 2Build reusable component classes instead of styling every tag globally.
- 1Using IDs everywhere (high specificity, hard to override).
- 2Writing overly long selectors that are fragile.
- 1Prefer class selectors for components.
- 2Keep specificity low; override by placing rules later or using a parent class.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css selectors class selector id selector attribute selector pseudo classCSS Combinators (References)
Combinators select elements by relationship: descendant, child, adjacent sibling, general sibling.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.card a { | Targets elements matching: .card a. |
color:#00e5ff | Sets `color` to `#00e5ff`. |
} | Ends the current rule block. |
ul > li { | Targets elements matching: ul > li. |
margin-top:6px | Sets `margin-top` to `6px`. |
} | Ends the current rule block. |
h2 + p { | Targets elements matching: h2 + p. |
margin-top:0 | Sets `margin-top` to `0`. |
} | Ends the current rule block. |
- 1Target buttons/links/forms precisely without adding extra HTML.
- 2Build reusable component classes instead of styling every tag globally.
- 1Using IDs everywhere (high specificity, hard to override).
- 2Writing overly long selectors that are fragile.
- 1Prefer class selectors for components.
- 2Keep specificity low; override by placing rules later or using a parent class.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css combinators descendant selector child selector adjacent sibling general siblingCSS Pseudo-classes (References)
Pseudo-classes target states: :hover, :focus-visible, :checked, :nth-child() and more.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
button:hover { | Targets elements matching: button:hover. |
filter:brightness(1.05) | Sets `filter` to `brightness(1.05)`. |
} | Ends the current rule block. |
input:checked + label { | Targets elements matching: input:checked + label. |
font-weight:800 | Sets `font-weight` to `800`. |
} | Ends the current rule block. |
li:nth-child(odd) { | Targets elements matching: li:nth-child(odd). |
opacity:.9 | Sets `opacity` to `.9`. |
} | Ends the current rule block. |
- 1Target buttons/links/forms precisely without adding extra HTML.
- 2Build reusable component classes instead of styling every tag globally.
- 1Using IDs everywhere (high specificity, hard to override).
- 2Writing overly long selectors that are fragile.
- 1Prefer class selectors for components.
- 2Keep specificity low; override by placing rules later or using a parent class.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
pseudo class hover focus visible nth-child checkedCSS Pseudo-elements (References)
Pseudo-elements style parts of elements: ::before, ::after, ::first-line, ::marker.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.pill::before { | Targets elements matching: .pill::before. |
content:"#"; | Sets `content` to `"#"`. |
opacity:.7; | Sets `opacity` to `.7`. |
margin-right:6px | Sets `margin-right` to `6px`. |
} | Ends the current rule block. |
li::marker { | Targets elements matching: li::marker. |
color:#ff4081 | Sets `color` to `#ff4081`. |
} | Ends the current rule block. |
- 1Target buttons/links/forms precisely without adding extra HTML.
- 2Build reusable component classes instead of styling every tag globally.
- 1Using IDs everywhere (high specificity, hard to override).
- 2Writing overly long selectors that are fragile.
- 1Prefer class selectors for components.
- 2Keep specificity low; override by placing rules later or using a parent class.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
pseudo element before after marker first-lineCSS At-rules
At-rules begin with @ and control features like media queries, keyframes, supports, and fonts.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
@media (max-width:700px) { | Targets elements matching: @media (max-width:700px). |
... | CSS statement. |
} | Ends the current rule block. |
@supports (display:grid) { | Targets elements matching: @supports (display:grid). |
... | CSS statement. |
} | Ends the current rule block. |
@keyframes spin { | Targets elements matching: @keyframes spin. |
to { | Targets elements matching: to. |
transform:rotate(1turn) | Sets `transform` to `rotate(1turn)`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css at-rules @media @keyframes @supports @font-faceCSS Functions
Functions like var(), calc(), clamp(), rgb(), and url() build powerful values.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.box { | Targets elements matching: .box. |
padding:calc(12px + 1vw); | Sets `padding` to `calc(12px + 1vw)`. |
color:rgb(34 211 238); | Sets `color` to `rgb(34 211 238)`. |
background:var(--surface) | Sets `background` to `var(--surface)`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css functions var calc clamp rgbCSS Reference Aural
Aural/speech CSS was experimental and is largely obsolete; focus on modern accessibility instead.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
aural css speech css obsolete css accessibility css historyCSS Web Safe Fonts
Web-safe fonts work everywhere. Use them as fallbacks even with custom fonts.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
body { | Targets elements matching: body. |
font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif | Sets `font-family` to `system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
web safe fonts font stack fallback fonts typography cssCSS Animatable
Not every property animates smoothly. Prefer transform/opacity for performance.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.card { | Targets elements matching: .card. |
transition:transform .2s ease, opacity .2s ease | Sets `transition` to `transform .2s ease, opacity .2s ease`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
animatable properties css animation performance transform opacity jankCSS Units (References)
Use px for fixed sizes, rem for scalable typography, and %/vw for responsive layouts.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
:root { | Targets elements matching: :root. |
font-size:16px | Sets `font-size` to `16px`. |
} | Ends the current rule block. |
h1 { | Targets elements matching: h1. |
font-size:2rem | Sets `font-size` to `2rem`. |
} | Ends the current rule block. |
.box { | Targets elements matching: .box. |
width:50vw; | Sets `width` to `50vw`. |
max-width:720px | Sets `max-width` to `720px`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css units px rem em vwCSS PX-EM Converter
Convert px to em/rem: em = px / baseFontSize (usually 16).
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
px to em px to rem css converter typography unitsCSS Colors (References)
CSS supports named colors, hex, rgb/rgba, hsl/hsla, and modern color functions.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.badge { | Targets elements matching: .badge. |
color:#0f172a; | Sets `color` to `#0f172a`. |
background:#ffd54f | Sets `background` to `#ffd54f`. |
} | Ends the current rule block. |
.overlay { | Targets elements matching: .overlay. |
background:rgba(2,6,23,.6) | Sets `background` to `rgba(2,6,23,.6)`. |
} | Ends the current rule block. |
.brand { | Targets elements matching: .brand. |
color:hsl(190 95% 45%) | Sets `color` to `hsl(190 95% 45%)`. |
} | Ends the current rule block. |
- 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
- 2Gradients and shadows can replace image assets for simple UI depth.
- 1Low contrast text (hard to read).
- 2Overusing heavy shadows and making UI look blurry.
- 1Aim for readable contrast; test quickly by lowering screen brightness.
- 2Prefer soft, low-opacity shadows and avoid stacking many effects.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css colors hex color rgb hsl rgbaCSS Color Values
Color values include hex, rgb/rgba, hsl/hsla, and named colors.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
.a { | Targets elements matching: .a. |
color:#00e5ff | Sets `color` to `#00e5ff`. |
} | Ends the current rule block. |
.b { | Targets elements matching: .b. |
color:rgb(124 77 255) | Sets `color` to `rgb(124 77 255)`. |
} | Ends the current rule block. |
.c { | Targets elements matching: .c. |
color:hsl(330 100% 62%) | Sets `color` to `hsl(330 100% 62%)`. |
} | Ends the current rule block. |
- 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
- 2Gradients and shadows can replace image assets for simple UI depth.
- 1Low contrast text (hard to read).
- 2Overusing heavy shadows and making UI look blurry.
- 1Aim for readable contrast; test quickly by lowering screen brightness.
- 2Prefer soft, low-opacity shadows and avoid stacking many effects.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css color values hex rgb hsl rgbaCSS Default Values
Browsers apply default styles (user agent stylesheet). Reset/normalize can help consistency.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
body { | Targets elements matching: body. |
margin:0 | Sets `margin` to `0`. |
} | Ends the current rule block. |
img { | Targets elements matching: img. |
max-width:100%; | Sets `max-width` to `100%`. |
height:auto | Sets `height` to `auto`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
css defaults user agent stylesheet normalize reset browser defaultCSS Browser Support
Use progressive enhancement: ship a baseline, then add modern features with fallbacks.
selector {
property: value;
}
Edit the example below. Keep the <style> section and experiment.
| Line | Meaning |
|---|---|
@supports (backdrop-filter: blur(10px)) { | Targets elements matching: @supports (backdrop-filter: blur(10px)). |
.glass { | Targets elements matching: .glass. |
backdrop-filter:blur(10px) | Sets `backdrop-filter` to `blur(10px)`. |
} | Ends the current rule block. |
} | Ends the current rule block. |
.glass { | Targets elements matching: .glass. |
background:rgba(255,255,255,.06) | Sets `background` to `rgba(255,255,255,.06)`. |
} | Ends the current rule block. |
- 1UI components (buttons, cards, navbars) use these rules daily.
- 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
- 1Use DevTools: inspect the element and check which rule wins.
- 1Understand the core concept, then practice it in a small UI component.
- 2Prefer simple rules that are easy to override and reuse.
- 1Change one thing, run, and explain the result in 1 sentence.
- 2Try to recreate the same look using a different property/approach.
- 3In DevTools, find which rule is winning and why.
Keywords (topic intent):
browser support progressive enhancement fallback @supports compatibility