Cascading Style Sheets

CSS — Complete Tutorial

Learn CSS from absolute zero. Every topic explained simply with real examples you can edit and run live, right here in your browser.

🟩 Beginner Friendly ▶ Live Code Editor 📚 125 Topics
Your Progress3% complete
Live CSS Lab

Edit the CSS below and click Run. The preview updates instantly so you can test styles quickly.

css-lab.php
📝 Edit Code
👁 Live Preview
💡 Try this: change --accent and verify button/title color update together.
∙ Chapter 001

CSS HOME

Start here: what CSS is, how it works, and how this tutorial is organized.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-home.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
*,*::before,*::after {Targets elements matching: *,*::before,*::after.
box-sizing:border-boxSets `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-serifSets `font-family` to `system-ui,Arial,sans-serif`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css tutorial css basics learn css stylesheets web design
∙ Chapter 002

CSS Introduction

CSS (Cascading Style Sheets) controls how HTML looks: colors, spacing, typography, and layout.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-introduction.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
h1 {Targets elements matching: h1.
color:rebeccapurpleSets `color` to `rebeccapurple`.
}Ends the current rule block.
p {Targets elements matching: p.
line-height:1.7Sets `line-height` to `1.7`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

what is css css introduction css basics html css stylesheet
∙ Chapter 003

CSS Syntax

A CSS rule is: selector + { property: value; }. Multiple rules cascade together.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-syntax.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css syntax selectors properties values rules
∙ Chapter 004

CSS Selectors

Selectors target elements (by tag, class, id, attributes, states) so you can style them.

📝Syntax
.btn { ... }
#hero { ... }
input[type="email"] { ... }
.btn:hover { ... }
.btn::before { ... }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-selectors.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
button.primary {Targets elements matching: button.primary.
background:#0ea5e9;Sets `background` to `#0ea5e9`.
color:#fffSets `color` to `#fff`.
}Ends the current rule block.
#hero {Targets elements matching: #hero.
padding:24pxSets `padding` to `24px`.
}Ends the current rule block.
input[type="email"] {Targets elements matching: input[type="email"].
border:1px solid #94a3b8Sets `border` to `1px solid #94a3b8`.
}Ends the current rule block.
🏢Real-world
  • 1Target buttons/links/forms precisely without adding extra HTML.
  • 2Build reusable component classes instead of styling every tag globally.
Common Mistakes
  • 1Using IDs everywhere (high specificity, hard to override).
  • 2Writing overly long selectors that are fragile.
Best Practices
  • 1Prefer class selectors for components.
  • 2Keep specificity low; override by placing rules later or using a parent class.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css selectors class selector id selector attribute selector pseudo class
∙ Chapter 005

CSS How To

Use CSS inline, in a <style> tag, or in an external .css file (best for real websites).

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-how-to.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
<link rel="stylesheet" href="styles.css">CSS statement.
<!-- OR -->CSS statement.
<style> .btn {Targets elements matching: <style> .btn.
padding:10px 14pxSets `padding` to `10px 14px`.
}Ends the current rule block.
</style>CSS statement.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

add css external stylesheet internal css inline css link css
∙ Chapter 006

CSS Comments

Comments help you document styles and temporarily disable rules while testing.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-comments.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.btn {Targets elements matching: .btn.
background:#22c55eSets `background` to `#22c55e`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css comments comment css debug css disable css readable css
∙ Chapter 007

CSS Errors

Most CSS “bugs” come from typos, invalid values, missing units, and specificity conflicts.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-errors.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.box {Targets elements matching: .box.
width:200Sets `width` to `200`.
}Ends the current rule block.
.title {Targets elements matching: .title.
colorr:tomatoSets `colorr` to `tomato`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css errors css debugging invalid property specificity devtools
∙ Chapter 008

CSS Colors

CSS supports named colors, hex, rgb/rgba, hsl/hsla, and modern color functions.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-colors.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.badge {Targets elements matching: .badge.
color:#0f172a;Sets `color` to `#0f172a`.
background:#ffd54fSets `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.
🏢Real-world
  • 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
  • 2Gradients and shadows can replace image assets for simple UI depth.
Common Mistakes
  • 1Low contrast text (hard to read).
  • 2Overusing heavy shadows and making UI look blurry.
Best Practices
  • 1Aim for readable contrast; test quickly by lowering screen brightness.
  • 2Prefer soft, low-opacity shadows and avoid stacking many effects.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css colors hex color rgb hsl rgba
∙ Chapter 009

CSS Backgrounds

Backgrounds can be solid, gradients, or images, and you control size, repeat, and position.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-backgrounds.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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.
🏢Real-world
  • 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
  • 2Gradients and shadows can replace image assets for simple UI depth.
Common Mistakes
  • 1Low contrast text (hard to read).
  • 2Overusing heavy shadows and making UI look blurry.
Best Practices
  • 1Aim for readable contrast; test quickly by lowering screen brightness.
  • 2Prefer soft, low-opacity shadows and avoid stacking many effects.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css background background image background size background position cover
∙ Chapter 010

CSS Borders

Borders surround elements; you can change width, style, color, and radius.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-borders.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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.
🏢Real-world
  • 1Consistent spacing and borders make layouts feel clean and professional.
  • 2Focus outlines improve keyboard usability.
Common Mistakes
  • 1Forgetting `box-sizing: border-box` and getting unexpected widths.
  • 2Using large fixed padding on small screens.
Best Practices
  • 1Set `*,*::before,*::after{box-sizing:border-box}` early.
  • 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css border border radius border styles outline box model
∙ Chapter 011

CSS Margins

Margin is the space outside an element. Use it to separate components.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-margins.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.stack > * + * {Targets elements matching: .stack > * + *.
margin-top:12pxSets `margin-top` to `12px`.
}Ends the current rule block.
.center {Targets elements matching: .center.
margin:0 auto;Sets `margin` to `0 auto`.
max-width:900pxSets `max-width` to `900px`.
}Ends the current rule block.
🏢Real-world
  • 1Consistent spacing and borders make layouts feel clean and professional.
  • 2Focus outlines improve keyboard usability.
Common Mistakes
  • 1Forgetting `box-sizing: border-box` and getting unexpected widths.
  • 2Using large fixed padding on small screens.
Best Practices
  • 1Set `*,*::before,*::after{box-sizing:border-box}` early.
  • 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css margin margin shorthand spacing layout box model
∙ Chapter 012

CSS Padding

Padding is the space inside an element, between its content and border.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-padding.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.btn {Targets elements matching: .btn.
padding:10px 14pxSets `padding` to `10px 14px`.
}Ends the current rule block.
.card {Targets elements matching: .card.
padding:18px 20pxSets `padding` to `18px 20px`.
}Ends the current rule block.
🏢Real-world
  • 1Consistent spacing and borders make layouts feel clean and professional.
  • 2Focus outlines improve keyboard usability.
Common Mistakes
  • 1Forgetting `box-sizing: border-box` and getting unexpected widths.
  • 2Using large fixed padding on small screens.
Best Practices
  • 1Set `*,*::before,*::after{box-sizing:border-box}` early.
  • 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css padding padding shorthand spacing box model ui spacing
∙ Chapter 013

CSS Height / Width

Set explicit sizes with width/height, or use responsive sizing with %, vw, and max-width.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-height-width.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.panel {Targets elements matching: .panel.
width:min(92vw,720px);Sets `width` to `min(92vw,720px)`.
min-height:220pxSets `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:999pxSets `border-radius` to `999px`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css width css height responsive sizing max width min height
∙ Chapter 014

CSS Box Model

Every element is a box: content → padding → border → margin. This affects layout and sizing.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-box-model.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
*,*::before,*::after {Targets elements matching: *,*::before,*::after.
box-sizing:border-boxSets `box-sizing` to `border-box`.
}Ends the current rule block.
🏢Real-world
  • 1Consistent spacing and borders make layouts feel clean and professional.
  • 2Focus outlines improve keyboard usability.
Common Mistakes
  • 1Forgetting `box-sizing: border-box` and getting unexpected widths.
  • 2Using large fixed padding on small screens.
Best Practices
  • 1Set `*,*::before,*::after{box-sizing:border-box}` early.
  • 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css box model margin padding border content
∙ Chapter 015

CSS Outline

Outline does not take layout space. It’s perfect for focus styles and accessibility.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-outline.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
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.
🏢Real-world
  • 1Consistent spacing and borders make layouts feel clean and professional.
  • 2Focus outlines improve keyboard usability.
Common Mistakes
  • 1Forgetting `box-sizing: border-box` and getting unexpected widths.
  • 2Using large fixed padding on small screens.
Best Practices
  • 1Set `*,*::before,*::after{box-sizing:border-box}` early.
  • 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css outline focus visible accessibility keyboard navigation ui
∙ Chapter 016

CSS Text

Text styling covers alignment, spacing, decoration, and overflow handling.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-text.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.title {Targets elements matching: .title.
letter-spacing:-.5pxSets `letter-spacing` to `-.5px`.
}Ends the current rule block.
.center {Targets elements matching: .center.
text-align:centerSets `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:ellipsisSets `text-overflow` to `ellipsis`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css text text align line height letter spacing text overflow
∙ Chapter 017

CSS Fonts

Choose readable fonts, control size/weight, and use fallbacks for reliability.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-fonts.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
body {Targets elements matching: body.
font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serifSets `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,monospaceSets `font-family` to `ui-monospace,Consolas,monospace`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css fonts font family font weight typography web fonts
∙ Chapter 018

CSS Icons

Icons are commonly delivered via SVG or icon fonts; style them with color and size.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-icons.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.icon {Targets elements matching: .icon.
width:18px;Sets `width` to `18px`.
height:18px;Sets `height` to `18px`.
fill:currentColorSets `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:centerSets `align-items` to `center`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css icons svg icon icon font font awesome inline svg
∙ Chapter 020

CSS Lists

Control markers, spacing, and make modern menus by removing default list styles.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-lists.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
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:12pxSets `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:10pxSets `border-radius` to `10px`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css lists list style ul li navigation markers
∙ Chapter 021

CSS Tables

Tables need spacing, borders, and zebra rows to be readable.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-tables.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
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:10pxSets `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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css tables table styling border collapse zebra rows responsive table
∙ Chapter 022

CSS Display

display controls layout behavior: block, inline, inline-block, flex, grid, none.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-display.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.pill {Targets elements matching: .pill.
display:inline-block;Sets `display` to `inline-block`.
padding:6px 10px;Sets `padding` to `6px 10px`.
border-radius:999pxSets `border-radius` to `999px`.
}Ends the current rule block.
.hidden {Targets elements matching: .hidden.
display:noneSets `display` to `none`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css display block inline inline-block none
∙ Chapter 023

CSS Max-width

max-width prevents content from stretching too wide and improves readability.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-max-width.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.container {Targets elements matching: .container.
max-width:1100px;Sets `max-width` to `1100px`.
margin:0 auto;Sets `margin` to `0 auto`.
padding:0 16pxSets `padding` to `0 16px`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css max width responsive layout readability container fluid
∙ Chapter 024

CSS Position

position lets you offset elements relative to normal flow (relative/absolute/fixed/sticky).

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-position.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.badge {Targets elements matching: .badge.
position:absolute;Sets `position` to `absolute`.
top:10px;Sets `top` to `10px`.
right:10pxSets `right` to `10px`.
}Ends the current rule block.
.sticky {Targets elements matching: .sticky.
position:sticky;Sets `position` to `sticky`.
top:0Sets `top` to `0`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css position relative absolute fixed sticky
∙ Chapter 025

CSS Position Offsets

Offsets are top/right/bottom/left (or inset). They work when position is not static.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-position-offsets.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.box {Targets elements matching: .box.
position:relative;Sets `position` to `relative`.
left:12px;Sets `left` to `12px`.
top:6pxSets `top` to `6px`.
}Ends the current rule block.
.box2 {Targets elements matching: .box2.
position:absolute;Sets `position` to `absolute`.
inset:12pxSets `inset` to `12px`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css top css left inset offsets position
∙ Chapter 026

CSS Z-index

z-index controls stacking order, but only works on positioned elements/stacking contexts.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-z-index.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.modal {Targets elements matching: .modal.
position:fixed;Sets `position` to `fixed`.
inset:0;Sets `inset` to `0`.
z-index:50Sets `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:60Sets `z-index` to `60`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css z-index stacking context position overlay modal
∙ Chapter 027

CSS Overflow

overflow controls clipping and scrolling for content that exceeds its box.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-overflow.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.scroller {Targets elements matching: .scroller.
max-height:180px;Sets `max-height` to `180px`.
overflow:autoSets `overflow` to `auto`.
}Ends the current rule block.
.clip {Targets elements matching: .clip.
overflow:hiddenSets `overflow` to `hidden`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css overflow scroll hidden auto clip
∙ Chapter 028

CSS Float

Float is mainly for wrapping text around images. Use Flexbox/Grid for layouts.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-float.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.pic {Targets elements matching: .pic.
float:left;Sets `float` to `left`.
margin:0 12px 10px 0;Sets `margin` to `0 12px 10px 0`.
width:120pxSets `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:bothSets `clear` to `both`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css float clear legacy layout wrap text clearfix
∙ Chapter 029

CSS Inline-block

inline-block flows inline like text but keeps block sizing (width/height).

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-inline-block.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:999pxSets `border-radius` to `999px`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

inline-block css display inline block layout
∙ Chapter 030

CSS Align

Alignment depends on layout mode: text-align for inline content; flex/grid for layouts.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-align.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.center-text {Targets elements matching: .center-text.
text-align:centerSets `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:centerSets `align-items` to `center`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css align justify-content align-items text-align center
∙ Chapter 031

CSS Combinators

Combinators select elements by relationship: descendant, child, adjacent sibling, general sibling.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-combinators.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.card a {Targets elements matching: .card a.
color:#00e5ffSets `color` to `#00e5ff`.
}Ends the current rule block.
ul > li {Targets elements matching: ul > li.
margin-top:6pxSets `margin-top` to `6px`.
}Ends the current rule block.
h2 + p {Targets elements matching: h2 + p.
margin-top:0Sets `margin-top` to `0`.
}Ends the current rule block.
🏢Real-world
  • 1Target buttons/links/forms precisely without adding extra HTML.
  • 2Build reusable component classes instead of styling every tag globally.
Common Mistakes
  • 1Using IDs everywhere (high specificity, hard to override).
  • 2Writing overly long selectors that are fragile.
Best Practices
  • 1Prefer class selectors for components.
  • 2Keep specificity low; override by placing rules later or using a parent class.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css combinators descendant selector child selector adjacent sibling general sibling
∙ Chapter 032

CSS Pseudo-classes

Pseudo-classes target states: :hover, :focus-visible, :checked, :nth-child() and more.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-pseudo-classes.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
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:800Sets `font-weight` to `800`.
}Ends the current rule block.
li:nth-child(odd) {Targets elements matching: li:nth-child(odd).
opacity:.9Sets `opacity` to `.9`.
}Ends the current rule block.
🏢Real-world
  • 1Target buttons/links/forms precisely without adding extra HTML.
  • 2Build reusable component classes instead of styling every tag globally.
Common Mistakes
  • 1Using IDs everywhere (high specificity, hard to override).
  • 2Writing overly long selectors that are fragile.
Best Practices
  • 1Prefer class selectors for components.
  • 2Keep specificity low; override by placing rules later or using a parent class.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

pseudo class hover focus visible nth-child checked
∙ Chapter 033

CSS Pseudo-elements

Pseudo-elements style parts of elements: ::before, ::after, ::first-line, ::marker.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-pseudo-elements.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.pill::before {Targets elements matching: .pill::before.
content:"#";Sets `content` to `"#"`.
opacity:.7;Sets `opacity` to `.7`.
margin-right:6pxSets `margin-right` to `6px`.
}Ends the current rule block.
li::marker {Targets elements matching: li::marker.
color:#ff4081Sets `color` to `#ff4081`.
}Ends the current rule block.
🏢Real-world
  • 1Target buttons/links/forms precisely without adding extra HTML.
  • 2Build reusable component classes instead of styling every tag globally.
Common Mistakes
  • 1Using IDs everywhere (high specificity, hard to override).
  • 2Writing overly long selectors that are fragile.
Best Practices
  • 1Prefer class selectors for components.
  • 2Keep specificity low; override by placing rules later or using a parent class.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

pseudo element before after marker first-line
∙ Chapter 034

CSS Opacity

opacity affects an entire element (including children). For only background, use rgba().

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-opacity.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.muted {Targets elements matching: .muted.
opacity:.65Sets `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.
🏢Real-world
  • 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
  • 2Gradients and shadows can replace image assets for simple UI depth.
Common Mistakes
  • 1Low contrast text (hard to read).
  • 2Overusing heavy shadows and making UI look blurry.
Best Practices
  • 1Aim for readable contrast; test quickly by lowering screen brightness.
  • 2Prefer soft, low-opacity shadows and avoid stacking many effects.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css opacity rgba transparent alpha overlay
∙ Chapter 035

CSS Navigation Bars

Navbars are usually flex layouts with spacing, hover styles, and a responsive toggle.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-navigation-bars.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.nav {Targets elements matching: .nav.
display:flex;Sets `display` to `flex`.
gap:14px;Sets `gap` to `14px`.
align-items:centerSets `align-items` to `center`.
}Ends the current rule block.
.nav a {Targets elements matching: .nav a.
padding:8px 10px;Sets `padding` to `8px 10px`.
border-radius:10px;Sets `border-radius` to `10px`.
text-decoration:noneSets `text-decoration` to `none`.
}Ends the current rule block.
.nav a:hover {Targets elements matching: .nav a:hover.
background:rgba(0,229,255,.08)Sets `background` to `rgba(0,229,255,.08)`.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css navbar navigation bar flex menu responsive navbar
∙ Chapter 036

CSS Dropdowns

Dropdowns can be built with :hover or :focus-within. Prefer keyboard-friendly patterns.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-dropdowns.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.dd {Targets elements matching: .dd.
position:relative;Sets `position` to `relative`.
display:inline-blockSets `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:0Sets `left` to `0`.
}Ends the current rule block.
.dd:focus-within .dd-menu {Targets elements matching: .dd:focus-within .dd-menu.
display:blockSets `display` to `block`.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css dropdown focus-within menu hover accessibility
∙ Chapter 038

CSS Image Sprites

Sprites pack many icons into one image to reduce requests (less needed with modern bundling).

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-image-sprites.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.icon {Targets elements matching: .icon.
width:24px;Sets `width` to `24px`.
height:24px;Sets `height` to `24px`.
background:url(sprite.png) no-repeatSets `background` to `url(sprite.png) no-repeat`.
}Ends the current rule block.
.icon.home {Targets elements matching: .icon.home.
background-position:0 0Sets `background-position` to `0 0`.
}Ends the current rule block.
.icon.user {Targets elements matching: .icon.user.
background-position:-24px 0Sets `background-position` to `-24px 0`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css sprite background-position icons performance sprite sheet
∙ Chapter 039

CSS Attribute Selectors

Select by attributes like type, href, or data-* for clean and predictable styling.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-attribute-selectors.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
input[type="password"] {Targets elements matching: input[type="password"].
letter-spacing:.25emSets `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:.7Sets `opacity` to `.7`.
}Ends the current rule block.
🏢Real-world
  • 1Target buttons/links/forms precisely without adding extra HTML.
  • 2Build reusable component classes instead of styling every tag globally.
Common Mistakes
  • 1Using IDs everywhere (high specificity, hard to override).
  • 2Writing overly long selectors that are fragile.
Best Practices
  • 1Prefer class selectors for components.
  • 2Keep specificity low; override by placing rules later or using a parent class.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

attribute selectors data attributes selectors css forms
∙ Chapter 040

CSS Forms

Form styling focuses on padding, borders, focus states, and spacing for readability.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-forms.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
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 #334155Sets `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:2pxSets `outline-offset` to `2px`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css forms input styling focus form layout accessibility
∙ Chapter 041

CSS Counters

Counters generate automatic numbering without editing HTML, useful for steps and headings.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-counters.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.steps {Targets elements matching: .steps.
counter-reset:stepSets `counter-reset` to `step`.
}Ends the current rule block.
.steps li {Targets elements matching: .steps li.
counter-increment:stepSets `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:900Sets `font-weight` to `900`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css counters counter-reset counter-increment steps numbering
∙ Chapter 042

CSS Units

Use px for fixed sizes, rem for scalable typography, and %/vw for responsive layouts.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-units.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
:root {Targets elements matching: :root.
font-size:16pxSets `font-size` to `16px`.
}Ends the current rule block.
h1 {Targets elements matching: h1.
font-size:2remSets `font-size` to `2rem`.
}Ends the current rule block.
.box {Targets elements matching: .box.
width:50vw;Sets `width` to `50vw`.
max-width:720pxSets `max-width` to `720px`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css units px rem em vw
∙ Chapter 043

CSS Inheritance

Some properties inherit (like color/font), others don’t (like margin). Use inherit/initial/unset.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-inheritance.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.panel {Targets elements matching: .panel.
color:#e2e8f0Sets `color` to `#e2e8f0`.
}Ends the current rule block.
.panel a {Targets elements matching: .panel a.
color:inheritSets `color` to `inherit`.
}Ends the current rule block.
.reset {Targets elements matching: .reset.
all:unsetSets `all` to `unset`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css inheritance inherit initial unset cascade
∙ Chapter 044

CSS Specificity

When rules conflict, specificity (and source order) decides which one wins.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-specificity.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
#btn {Targets elements matching: #btn.
background:redSets `background` to `red`.
}Ends the current rule block.
.btn {Targets elements matching: .btn.
background:greenSets `background` to `green`.
}Ends the current rule block.
🏢Real-world
  • 1Debugging CSS quickly depends on understanding cascade + specificity.
  • 2Design systems rely on predictable overrides.
Common Mistakes
  • 1Using `!important` everywhere.
  • 2Chasing overrides by making selectors longer and longer.
Best Practices
  • 1Use a component root class (ex: `.app`) to scope overrides.
  • 2Keep a consistent order: base → components → utilities.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css specificity cascade id vs class important selectors
∙ Chapter 045

CSS !important

Use !important only as a last resort (e.g., utility overrides). Prefer better structure.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-important.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.text-muted {Targets elements matching: .text-muted.
color:#94a3b8 !importantSets `color` to `#94a3b8 !important`.
}Ends the current rule block.
🏢Real-world
  • 1Debugging CSS quickly depends on understanding cascade + specificity.
  • 2Design systems rely on predictable overrides.
Common Mistakes
  • 1Using `!important` as a default (hard to maintain).
  • 2Forgetting that `!important` still follows specificity rules among important declarations.
  • 3Breaking theming because important overrides tokens.
Best Practices
  • 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.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css important !important override specificity utilities
∙ Chapter 046

CSS Math Functions

Use calc(), min(), max(), and clamp() to build fluid, responsive values.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-math-functions.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css calc css clamp min max responsive typography fluid spacing
∙ Chapter 047

CSS Optimization

Keep CSS fast by reducing unused styles, avoiding expensive selectors, and using modern layout tools.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-optimization.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.btn {Targets elements matching: .btn.
...CSS statement.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css optimization performance critical css reduce unused css best practices
∙ Chapter 048

CSS Accessibility

Accessible CSS means readable contrast, visible focus, reduced motion options, and clear states.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-accessibility.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
@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 !importantSets `transition` to `none !important`.
}Ends the current rule block.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css accessibility focus visible contrast reduced motion a11y
∙ Chapter 049

CSS Website Layout

Modern layouts use Grid for overall page structure and Flexbox for component alignment.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-website-layout.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:100vhSets `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:1frSets `grid-template-columns` to `1fr`.
}Ends the current rule block.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css layout grid layout flexbox layout website layout responsive layout
CSS Advanced
∙ Chapter 050

CSS Rounded Corners

Use border-radius for rounded shapes; large radius creates pills and circles.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-rounded-corners.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.card {Targets elements matching: .card.
border-radius:16pxSets `border-radius` to `16px`.
}Ends the current rule block.
.pill {Targets elements matching: .pill.
border-radius:999pxSets `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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

border-radius rounded corners pill circle ui
∙ Chapter 051

CSS Border Images

border-image lets you use an image (or gradient) as the border of an element.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-border-images.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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.
🏢Real-world
  • 1Consistent spacing and borders make layouts feel clean and professional.
  • 2Focus outlines improve keyboard usability.
Common Mistakes
  • 1Forgetting `box-sizing: border-box` and getting unexpected widths.
  • 2Using large fixed padding on small screens.
Best Practices
  • 1Set `*,*::before,*::after{box-sizing:border-box}` early.
  • 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

border-image css borders decorative border slice repeat
∙ Chapter 052

CSS Backgrounds (Advanced)

Backgrounds can be solid, gradients, or images, and you control size, repeat, and position.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-backgrounds.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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.
🏢Real-world
  • 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
  • 2Gradients and shadows can replace image assets for simple UI depth.
Common Mistakes
  • 1Low contrast text (hard to read).
  • 2Overusing heavy shadows and making UI look blurry.
Best Practices
  • 1Aim for readable contrast; test quickly by lowering screen brightness.
  • 2Prefer soft, low-opacity shadows and avoid stacking many effects.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css background background image background size background position cover
∙ Chapter 053

CSS Colors (Advanced)

CSS supports named colors, hex, rgb/rgba, hsl/hsla, and modern color functions.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-colors.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.badge {Targets elements matching: .badge.
color:#0f172a;Sets `color` to `#0f172a`.
background:#ffd54fSets `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.
🏢Real-world
  • 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
  • 2Gradients and shadows can replace image assets for simple UI depth.
Common Mistakes
  • 1Low contrast text (hard to read).
  • 2Overusing heavy shadows and making UI look blurry.
Best Practices
  • 1Aim for readable contrast; test quickly by lowering screen brightness.
  • 2Prefer soft, low-opacity shadows and avoid stacking many effects.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css colors hex color rgb hsl rgba
∙ Chapter 054

CSS Gradients

Gradients create smooth transitions between colors without images.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-gradients.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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.
🏢Real-world
  • 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
  • 2Gradients and shadows can replace image assets for simple UI depth.
Common Mistakes
  • 1Low contrast text (hard to read).
  • 2Overusing heavy shadows and making UI look blurry.
Best Practices
  • 1Aim for readable contrast; test quickly by lowering screen brightness.
  • 2Prefer soft, low-opacity shadows and avoid stacking many effects.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css gradients linear-gradient radial-gradient background design
∙ Chapter 055

CSS Shadows

box-shadow adds depth to components; text-shadow can improve contrast carefully.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-shadows.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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.
🏢Real-world
  • 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
  • 2Gradients and shadows can replace image assets for simple UI depth.
Common Mistakes
  • 1Low contrast text (hard to read).
  • 2Overusing heavy shadows and making UI look blurry.
Best Practices
  • 1Aim for readable contrast; test quickly by lowering screen brightness.
  • 2Prefer soft, low-opacity shadows and avoid stacking many effects.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

box-shadow text-shadow elevation depth ui
∙ Chapter 056

CSS Text Effects

Use text-shadow, strokes, and clipping with care so text stays readable.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-text-effects.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:transparentSets `color` to `transparent`.
}Ends the current rule block.
🏢Real-world
  • 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
  • 2Gradients and shadows can replace image assets for simple UI depth.
Common Mistakes
  • 1Low contrast text (hard to read).
  • 2Overusing heavy shadows and making UI look blurry.
Best Practices
  • 1Aim for readable contrast; test quickly by lowering screen brightness.
  • 2Prefer soft, low-opacity shadows and avoid stacking many effects.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

text effects text-shadow text stroke gradient text typography
∙ Chapter 057

CSS Custom Fonts

Load fonts using @font-face or providers. Always keep fallbacks for reliability.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-custom-fonts.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
@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-serifSets `font-family` to `MyFont,system-ui,sans-serif`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

custom fonts @font-face web fonts typography fallback fonts
∙ Chapter 058

CSS 2D Transforms

Transform elements with translate/rotate/scale without affecting layout.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-2d-transforms.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

2d transforms translate rotate scale transform
∙ Chapter 059

CSS 3D Transforms

3D transforms add perspective and depth (use sparingly).

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-3d-transforms.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.card {Targets elements matching: .card.
transform:perspective(900px) rotateY(12deg);Sets `transform` to `perspective(900px) rotateY(12deg)`.
transform-style:preserve-3dSets `transform-style` to `preserve-3d`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

3d transforms perspective rotateY transform-style 3d
∙ Chapter 060

CSS Transitions

Transitions animate property changes smoothly (hover, focus, state classes).

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-transitions.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.btn {Targets elements matching: .btn.
transition:transform .2s ease, filter .2s easeSets `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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css transitions transition property ease hover animation ui
∙ Chapter 061

CSS Animations

Animations use @keyframes for repeated motion; respect reduced-motion preferences.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-animations.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
@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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css animations @keyframes animation motion prefers-reduced-motion
∙ Chapter 062

CSS Tooltips

Tooltips can be built with pseudo-elements and appear on hover/focus.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-tooltips.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.tip {Targets elements matching: .tip.
position:relativeSets `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`.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css tooltip pseudo element hover focus ui
∙ Chapter 063

CSS Image Styling

Images often need border-radius, shadows, and object-fit to look consistent.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-image-styling.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

image styling border-radius object-fit responsive image css
∙ Chapter 064

CSS Image Modal

A modal is an overlay. Use fixed positioning and a centered panel.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-image-modal.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:centerSets `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:92vwSets `max-width` to `92vw`.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

image modal css modal overlay z-index dialog
∙ Chapter 065

CSS Image Centering

Center images with display:block + margin:auto or via flex/grid containers.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-image-centering.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
img.center {Targets elements matching: img.center.
display:block;Sets `display` to `block`.
margin:0 autoSets `margin` to `0 auto`.
}Ends the current rule block.
.wrap {Targets elements matching: .wrap.
display:grid;Sets `display` to `grid`.
place-items:centerSets `place-items` to `center`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

center image margin auto flex center grid center css
∙ Chapter 066

CSS Image Filters

Filters adjust visuals (blur, grayscale, contrast). Use lightly to avoid readability issues.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-image-filters.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
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:noneSets `filter` to `none`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css filter grayscale blur brightness image effects
∙ Chapter 067

CSS Image Shapes

Use border-radius and clip-path to create circles and custom shapes.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-image-shapes.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

clip-path image shapes circle image polygon css
∙ Chapter 068

CSS object-fit

object-fit controls how replaced content (images/videos) fill their box.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-object-fit.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
img {Targets elements matching: img.
width:260px;Sets `width` to `260px`.
height:160px;Sets `height` to `160px`.
object-fit:coverSets `object-fit` to `cover`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

object-fit cover contain responsive images cropping
∙ Chapter 069

CSS object-position

object-position chooses which part of an image stays visible when cropping.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-object-position.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
img {Targets elements matching: img.
object-fit:cover;Sets `object-fit` to `cover`.
object-position:top centerSets `object-position` to `top center`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

object-position image crop top center cover
∙ Chapter 070

CSS Masking

Masking hides parts of an element using an image/gradient (browser support varies).

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-masking.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css masking mask-image gradient mask clip effects
∙ Chapter 071

CSS Buttons

Buttons need good padding, hover/focus styles, and consistent colors.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-buttons.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:#fffSets `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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css button button style hover focus ui
∙ Chapter 072

CSS Pagination

Pagination is a row of links; style active and hover states clearly.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-pagination.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.pager {Targets elements matching: .pager.
display:flex;Sets `display` to `flex`.
gap:8pxSets `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:noneSets `text-decoration` to `none`.
}Ends the current rule block.
.pager a.active {Targets elements matching: .pager a.active.
background:#00e5ff;Sets `background` to `#00e5ff`.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css pagination active page nav links ui
∙ Chapter 073

CSS Multiple Columns

Multi-column layout splits text into columns (like a newspaper).

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-multiple-columns.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.cols {Targets elements matching: .cols.
column-count:3;Sets `column-count` to `3`.
column-gap:18pxSets `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:1Sets `column-count` to `1`.
}Ends the current rule block.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css columns multi column column-count column-gap layout
∙ Chapter 074

CSS User Interface

UI properties include cursor, resize, appearance, and accent-color for controls.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-user-interface.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
:root {Targets elements matching: :root.
accent-color:#00e5ffSets `accent-color` to `#00e5ff`.
}Ends the current rule block.
textarea {Targets elements matching: textarea.
resize:verticalSets `resize` to `vertical`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css ui accent-color appearance resize cursor
∙ Chapter 075

CSS Variables

Custom properties (variables) let you reuse values and theme a site quickly.

📝Syntax
:root { --accent: #00e5ff; }
.btn { background: var(--accent); }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-variables.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
:root {Targets elements matching: :root.
--brand:#00e5ffSets `--brand` to `#00e5ff`.
}Ends the current rule block.
.btn {Targets elements matching: .btn.
background:var(--brand);Sets `background` to `var(--brand)`.
color:#001018Sets `color` to `#001018`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css variables custom properties :root theming design tokens
∙ Chapter 076

CSS @property

@property registers typed custom properties so transitions/animations behave correctly.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-at-property.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
@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 easeSets `transition` to `--a .6s ease`.
}Ends the current rule block.
.ring:hover {Targets elements matching: .ring:hover.
--a:180degSets `--a` to `180deg`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css @property custom properties typed variables animation houdini
∙ Chapter 077

CSS Box Sizing

box-sizing: border-box makes layouts simpler because padding/border count inside width.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-box-sizing.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
*,*::before,*::after {Targets elements matching: *,*::before,*::after.
box-sizing:border-boxSets `box-sizing` to `border-box`.
}Ends the current rule block.
🏢Real-world
  • 1Consistent spacing and borders make layouts feel clean and professional.
  • 2Focus outlines improve keyboard usability.
Common Mistakes
  • 1Forgetting `box-sizing: border-box` and getting unexpected widths.
  • 2Using large fixed padding on small screens.
Best Practices
  • 1Set `*,*::before,*::after{box-sizing:border-box}` early.
  • 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

box-sizing border-box layout box model reset
∙ Chapter 078

CSS Media Queries

Media queries adapt styles based on viewport size or user preferences.

📝Syntax
@media (max-width: 600px) {
  .layout { grid-template-columns: 1fr; }
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-media-queries.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
@media (max-width:700px) {Targets elements matching: @media (max-width:700px).
.sidebar {Targets elements matching: .sidebar.
display:noneSets `display` to `none`.
}Ends the current rule block.
}Ends the current rule block.
🏢Real-world
  • 1Make layouts adapt to phones, tablets, and desktops.
  • 2Respect user preferences like reduced motion and dark mode.
Common Mistakes
  • 1Choosing breakpoints by device names (instead of where layout breaks).
  • 2Animating layout properties causing jank on mobile.
Best Practices
  • 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
  • 2Add `prefers-reduced-motion` fallback for animations.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

media queries responsive breakpoints prefers-color-scheme css
CSS Flexbox
∙ Chapter 079

Flexbox Intro

Flexbox is perfect for one-direction layouts (rows OR columns) with easy alignment.

📝Syntax
.row { display: flex; gap: 12px; }
.item { flex: 1; }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

flexbox-intro.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.row {Targets elements matching: .row.
display:flex;Sets `display` to `flex`.
gap:10pxSets `gap` to `10px`.
}Ends the current rule block.
.row > * {Targets elements matching: .row > *.
flex:1Sets `flex` to `1`.
}Ends the current rule block.
🏢Real-world
  • 1Consistent spacing and borders make layouts feel clean and professional.
  • 2Focus outlines improve keyboard usability.
Common Mistakes
  • 1Forgetting `box-sizing: border-box` and getting unexpected widths.
  • 2Using large fixed padding on small screens.
Best Practices
  • 1Set `*,*::before,*::after{box-sizing:border-box}` early.
  • 2Use `gap` for layout spacing (Flex/Grid) and padding for internal spacing.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

flexbox display flex alignment layout css flex
∙ Chapter 080

Flex Container

Container properties like justify-content and align-items control how items align.

📝Syntax
.row { display: flex; gap: 12px; }
.item { flex: 1; }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

flex-container.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:wrapSets `flex-wrap` to `wrap`.
}Ends the current rule block.
🏢Real-world
  • 1Navbars, toolbars, chip rows, and card footers are usually Flexbox.
  • 2Centering and spacing items becomes simple.
Common Mistakes
  • 1Forgetting `flex-wrap` and breaking mobile layout.
  • 2Mixing `gap` and margins randomly (inconsistent).
Best Practices
  • 1Use `gap` for spacing between flex items.
  • 2Use `flex: 1 1 ...` for responsive cards/chips.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

justify-content align-items flex container gap flex-wrap
∙ Chapter 081

Flex Items

Item properties like flex, align-self, and order control a single element’s behavior.

📝Syntax
.row { display: flex; gap: 12px; }
.item { flex: 1; }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

flex-items.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.item {Targets elements matching: .item.
flex:1 1 180pxSets `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:stretchSets `align-self` to `stretch`.
}Ends the current rule block.
🏢Real-world
  • 1Navbars, toolbars, chip rows, and card footers are usually Flexbox.
  • 2Centering and spacing items becomes simple.
Common Mistakes
  • 1Forgetting `flex-wrap` and breaking mobile layout.
  • 2Mixing `gap` and margins randomly (inconsistent).
Best Practices
  • 1Use `gap` for spacing between flex items.
  • 2Use `flex: 1 1 ...` for responsive cards/chips.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

flex flex-basis flex-grow align-self order
∙ Chapter 082

Flex Responsive

Make flex layouts responsive with wrapping and media queries.

📝Syntax
.row { display: flex; gap: 12px; }
.item { flex: 1; }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

flex-responsive.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.row {Targets elements matching: .row.
display:flex;Sets `display` to `flex`.
gap:12px;Sets `gap` to `12px`.
flex-wrap:wrapSets `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:columnSets `flex-direction` to `column`.
}Ends the current rule block.
}Ends the current rule block.
🏢Real-world
  • 1Navbars, toolbars, chip rows, and card footers are usually Flexbox.
  • 2Centering and spacing items becomes simple.
Common Mistakes
  • 1Forgetting `flex-wrap` and breaking mobile layout.
  • 2Mixing `gap` and margins randomly (inconsistent).
Best Practices
  • 1Use `gap` for spacing between flex items.
  • 2Use `flex: 1 1 ...` for responsive cards/chips.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

responsive flexbox flex-wrap breakpoints stack on mobile css
CSS Grid
∙ Chapter 083

Grid Intro

CSS Grid is ideal for 2D layouts: rows and columns together.

📝Syntax
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cell { ... }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

grid-intro.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:12pxSets `gap` to `12px`.
}Ends the current rule block.
🏢Real-world
  • 1Page layouts, galleries, dashboards, and responsive cards use Grid.
  • 2Two-dimensional alignment is much easier than with floats.
Common Mistakes
  • 1Hardcoding column counts instead of using responsive tracks.
  • 2Forgetting `minmax(0,1fr)` and causing overflow.
Best Practices
  • 1Use `repeat(auto-fit, minmax(160px, 1fr))` for responsive grids.
  • 2Use `grid-template-areas` for readable page layouts.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css grid grid layout rows and columns layout responsive
∙ Chapter 084

Grid Container

Define columns/rows with grid-template and control spacing using gap.

📝Syntax
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cell { ... }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

grid-container.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:12pxSets `gap` to `12px`.
}Ends the current rule block.
🏢Real-world
  • 1Page layouts, galleries, dashboards, and responsive cards use Grid.
  • 2Two-dimensional alignment is much easier than with floats.
Common Mistakes
  • 1Hardcoding column counts instead of using responsive tracks.
  • 2Forgetting `minmax(0,1fr)` and causing overflow.
Best Practices
  • 1Use `repeat(auto-fit, minmax(160px, 1fr))` for responsive grids.
  • 2Use `grid-template-areas` for readable page layouts.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

grid-template-columns grid-template-rows gap grid auto flow grid container
∙ Chapter 085

Grid Items

Place items using grid-column/grid-row or the shorthand grid-area.

📝Syntax
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cell { ... }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

grid-items.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.item.hero {Targets elements matching: .item.hero.
grid-column:1 / -1Sets `grid-column` to `1 / -1`.
}Ends the current rule block.
.item.sidebar {Targets elements matching: .item.sidebar.
grid-row:2 / 4Sets `grid-row` to `2 / 4`.
}Ends the current rule block.
🏢Real-world
  • 1Page layouts, galleries, dashboards, and responsive cards use Grid.
  • 2Two-dimensional alignment is much easier than with floats.
Common Mistakes
  • 1Hardcoding column counts instead of using responsive tracks.
  • 2Forgetting `minmax(0,1fr)` and causing overflow.
Best Practices
  • 1Use `repeat(auto-fit, minmax(160px, 1fr))` for responsive grids.
  • 2Use `grid-template-areas` for readable page layouts.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

grid-column grid-row grid-area place-items grid
∙ Chapter 086

Grid 12-column Layout

A 12-column grid is a common responsive system for dashboards and websites.

📝Syntax
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cell { ... }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

grid-12-column-layout.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:12pxSets `gap` to `12px`.
}Ends the current rule block.
.span6 {Targets elements matching: .span6.
grid-column:span 6Sets `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 12Sets `grid-column` to `span 12`.
}Ends the current rule block.
🏢Real-world
  • 1Page layouts, galleries, dashboards, and responsive cards use Grid.
  • 2Two-dimensional alignment is much easier than with floats.
Common Mistakes
  • 1Hardcoding column counts instead of using responsive tracks.
  • 2Forgetting `minmax(0,1fr)` and causing overflow.
Best Practices
  • 1Use `repeat(auto-fit, minmax(160px, 1fr))` for responsive grids.
  • 2Use `grid-template-areas` for readable page layouts.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

12 column grid grid system responsive grid layout css
∙ Chapter 087

CSS @supports

Feature queries let you apply styles only if the browser supports a property/value.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-supports.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
@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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

@supports feature queries progressive enhancement fallback css
CSS Responsive
∙ Chapter 088

RWD Intro

Responsive Web Design (RWD) makes layouts adapt to different screen sizes.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

rwd-intro.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.grid {Targets elements matching: .grid.
display:grid;Sets `display` to `grid`.
grid-template-columns:1frSets `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 1frSets `grid-template-columns` to `260px 1fr`.
}Ends the current rule block.
}Ends the current rule block.
🏢Real-world
  • 1Make layouts adapt to phones, tablets, and desktops.
  • 2Respect user preferences like reduced motion and dark mode.
Common Mistakes
  • 1Choosing breakpoints by device names (instead of where layout breaks).
  • 2Animating layout properties causing jank on mobile.
Best Practices
  • 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
  • 2Add `prefers-reduced-motion` fallback for animations.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

responsive web design rwd mobile first breakpoints css
∙ Chapter 089

RWD Viewport

The viewport meta tag is required so mobile browsers size the page correctly.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

rwd-viewport.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
<meta name="viewport" content="width=device-width, initial-scale=1.0">CSS statement.
🏢Real-world
  • 1Make layouts adapt to phones, tablets, and desktops.
  • 2Respect user preferences like reduced motion and dark mode.
Common Mistakes
  • 1Choosing breakpoints by device names (instead of where layout breaks).
  • 2Animating layout properties causing jank on mobile.
Best Practices
  • 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
  • 2Add `prefers-reduced-motion` fallback for animations.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

viewport meta mobile viewport responsive device width html head
∙ Chapter 090

RWD Grid View

Use Grid for page structure, then adjust columns at breakpoints.

📝Syntax
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cell { ... }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

rwd-grid-view.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:12pxSets `gap` to `12px`.
}Ends the current rule block.
.main {Targets elements matching: .main.
grid-column:1 / -1Sets `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 / -1Sets `grid-column` to `4 / -1`.
}Ends the current rule block.
🏢Real-world
  • 1Page layouts, galleries, dashboards, and responsive cards use Grid.
  • 2Two-dimensional alignment is much easier than with floats.
Common Mistakes
  • 1Hardcoding column counts instead of using responsive tracks.
  • 2Forgetting `minmax(0,1fr)` and causing overflow.
Best Practices
  • 1Use `repeat(auto-fit, minmax(160px, 1fr))` for responsive grids.
  • 2Use `grid-template-areas` for readable page layouts.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

responsive grid css grid breakpoints layout columns
∙ Chapter 091

RWD Media Queries

Breakpoints are simply media queries where your layout needs to change.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

rwd-media-queries.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
@media(max-width:640px) {Targets elements matching: @media(max-width:640px).
.nav {Targets elements matching: .nav.
display:noneSets `display` to `none`.
}Ends the current rule block.
}Ends the current rule block.
🏢Real-world
  • 1Make layouts adapt to phones, tablets, and desktops.
  • 2Respect user preferences like reduced motion and dark mode.
Common Mistakes
  • 1Choosing breakpoints by device names (instead of where layout breaks).
  • 2Animating layout properties causing jank on mobile.
Best Practices
  • 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
  • 2Add `prefers-reduced-motion` fallback for animations.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

responsive media queries breakpoints mobile first css layout
∙ Chapter 092

RWD Images

Make images scale with the container to prevent horizontal scroll.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

rwd-images.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
img {Targets elements matching: img.
max-width:100%;Sets `max-width` to `100%`.
height:auto;Sets `height` to `auto`.
display:blockSets `display` to `block`.
}Ends the current rule block.
🏢Real-world
  • 1Make layouts adapt to phones, tablets, and desktops.
  • 2Respect user preferences like reduced motion and dark mode.
Common Mistakes
  • 1Choosing breakpoints by device names (instead of where layout breaks).
  • 2Animating layout properties causing jank on mobile.
Best Practices
  • 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
  • 2Add `prefers-reduced-motion` fallback for animations.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

responsive images max-width height auto css img
∙ Chapter 093

RWD Videos

Use an aspect-ratio wrapper for responsive iframes/videos.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

rwd-videos.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.ratio {Targets elements matching: .ratio.
aspect-ratio:16/9Sets `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:0Sets `border` to `0`.
}Ends the current rule block.
🏢Real-world
  • 1Make layouts adapt to phones, tablets, and desktops.
  • 2Respect user preferences like reduced motion and dark mode.
Common Mistakes
  • 1Choosing breakpoints by device names (instead of where layout breaks).
  • 2Animating layout properties causing jank on mobile.
Best Practices
  • 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
  • 2Add `prefers-reduced-motion` fallback for animations.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

responsive video aspect-ratio iframe css embed
∙ Chapter 094

RWD Frameworks

Frameworks (Bootstrap/Tailwind) speed up responsive UI. Learn core CSS first.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

rwd-frameworks.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
🏢Real-world
  • 1Make layouts adapt to phones, tablets, and desktops.
  • 2Respect user preferences like reduced motion and dark mode.
Common Mistakes
  • 1Choosing breakpoints by device names (instead of where layout breaks).
  • 2Animating layout properties causing jank on mobile.
Best Practices
  • 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
  • 2Add `prefers-reduced-motion` fallback for animations.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

bootstrap tailwind responsive framework css utility grid system
∙ Chapter 095

RWD Templates

Start from a layout template, then customize spacing, typography, and colors.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

rwd-templates.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.page {Targets elements matching: .page.
min-height:100vh;Sets `min-height` to `100vh`.
display:grid;Sets `display` to `grid`.
grid-template-rows:auto 1fr autoSets `grid-template-rows` to `auto 1fr auto`.
}Ends the current rule block.
🏢Real-world
  • 1Make layouts adapt to phones, tablets, and desktops.
  • 2Respect user preferences like reduced motion and dark mode.
Common Mistakes
  • 1Choosing breakpoints by device names (instead of where layout breaks).
  • 2Animating layout properties causing jank on mobile.
Best Practices
  • 1Build mobile-first: base styles for small screens, then `@media (min-width: ...)` enhancements.
  • 2Add `prefers-reduced-motion` fallback for animations.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

responsive templates layout template starter css website
CSS SASS
∙ Chapter 096

SASS Tutorial

Sass adds variables, nesting, and functions. It compiles to normal CSS.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

sass-tutorial.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
$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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

sass scss variables nesting css preprocessor
CSS Examples
∙ Chapter 097

CSS Templates

Templates are ready-made layouts. Use them to learn structure and spacing patterns.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-templates.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:12pxSets `gap` to `12px`.
}Ends the current rule block.
.nav {Targets elements matching: .nav.
grid-area:navSets `grid-area` to `nav`.
}Ends the current rule block.
.side {Targets elements matching: .side.
grid-area:sideSets `grid-area` to `side`.
}Ends the current rule block.
.main {Targets elements matching: .main.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css templates layout starter template responsive ui
∙ Chapter 098

CSS Examples

Short examples help you learn one concept at a time.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-examples.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:999pxSets `border-radius` to `999px`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css examples snippets learn by example css code practice
∙ Chapter 099

CSS Editor

Use a live editor to test CSS quickly (this page already includes a live CSS lab).

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-editor.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.box {Targets elements matching: .box.
padding:16px;Sets `padding` to `16px`.
border:1px dashed #00e5ffSets `border` to `1px dashed #00e5ff`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css editor live preview playground try css sandbox
∙ Chapter 100

CSS Snippets

Snippets are reusable patterns like cards, buttons, gradients, and layouts.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-snippets.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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:18pxSets `padding` to `18px`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css snippets ui patterns reusable css components design
∙ Chapter 101

CSS Quiz

Quick quiz: test concepts like selectors, box model, and specificity.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-quiz.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css quiz css questions practice learn css mcq
∙ Chapter 102

CSS Exercises

Exercises help you build muscle memory by writing CSS from scratch.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-exercises.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.card {Targets elements matching: .card.
padding:16px;Sets `padding` to `16px`.
border-radius:14px;Sets `border-radius` to `14px`.
border:1px solid #334155Sets `border` to `1px solid #334155`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css exercises practice css learn css challenges training
∙ Chapter 103

CSS Code Challenges

Challenges combine multiple concepts (layout + typography + states).

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-code-challenges.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.nav {Targets elements matching: .nav.
display:flex;Sets `display` to `flex`.
justify-content:space-between;Sets `justify-content` to `space-between`.
align-items:centerSets `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:stretchSets `align-items` to `stretch`.
}Ends the current rule block.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css challenges projects practice ui layout
∙ Chapter 104

CSS Website

Build a small website to apply everything: layout, components, responsiveness, and accessibility.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-website.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.page {Targets elements matching: .page.
min-height:100vh;Sets `min-height` to `100vh`.
display:grid;Sets `display` to `grid`.
grid-template-rows:auto 1fr autoSets `grid-template-rows` to `auto 1fr auto`.
}Ends the current rule block.
header,footer {Targets elements matching: header,footer.
padding:16pxSets `padding` to `16px`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

build website css project responsive website portfolio layout
∙ Chapter 105

CSS Syllabus

A syllabus is a checklist of topics. Use it to track learning progress.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-syllabus.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css syllabus css roadmap learning path topics plan
∙ Chapter 106

CSS Study Plan

A simple plan: learn basics → build components → learn layout → ship a mini project.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-study-plan.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
Week 1: selectors + box modelSets `Week 1` to `selectors + box model`.
Week 2: typography + componentsSets `Week 2` to `typography + components`.
Week 3: flexbox + gridSets `Week 3` to `flexbox + grid`.
Week 4: responsive + a11y + projectSets `Week 4` to `responsive + a11y + project`.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css study plan roadmap learn css fast practice projects
∙ Chapter 107

CSS Interview Prep

Common interview topics: specificity, box model, layout, and responsive strategies.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-interview-prep.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.center {Targets elements matching: .center.
display:grid;Sets `display` to `grid`.
place-items:center;Sets `place-items` to `center`.
min-height:100vhSets `min-height` to `100vh`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css interview frontend interview css questions specificity box model
∙ Chapter 108

CSS Bootcamp

Bootcamp mode: build 10 UI components and 3 full layouts with reviews and refactors.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-bootcamp.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
Day 1: Buttons + InputsSets `Day 1` to `Buttons + Inputs`.
Day 2: Cards + ModalsSets `Day 2` to `Cards + Modals`.
Day 3: Navbar + SidebarSets `Day 3` to `Navbar + Sidebar`.
Day 4: Grid layoutSets `Day 4` to `Grid layout`.
Day 5: Responsive + A11ySets `Day 5` to `Responsive + A11y`.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css bootcamp intensive projects components practice
∙ Chapter 109

CSS Certificate

A certificate typically requires a final project and a knowledge test.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-certificate.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css certificate css certification frontend project exam
CSS References
∙ Chapter 110

CSS Reference

A quick reference of properties, selectors, and patterns you use daily.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-reference.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
display: flex | grid | blockSets `display` to `flex | grid | block`.
position: relative | absolute | fixed | stickySets `position` to `relative | absolute | fixed | sticky`.
box-sizing: border-boxSets `box-sizing` to `border-box`.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css reference properties selectors cheatsheet css docs
∙ Chapter 111

CSS Selectors (References)

Selectors target elements (by tag, class, id, attributes, states) so you can style them.

📝Syntax
.btn { ... }
#hero { ... }
input[type="email"] { ... }
.btn:hover { ... }
.btn::before { ... }
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-selectors.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
button.primary {Targets elements matching: button.primary.
background:#0ea5e9;Sets `background` to `#0ea5e9`.
color:#fffSets `color` to `#fff`.
}Ends the current rule block.
#hero {Targets elements matching: #hero.
padding:24pxSets `padding` to `24px`.
}Ends the current rule block.
input[type="email"] {Targets elements matching: input[type="email"].
border:1px solid #94a3b8Sets `border` to `1px solid #94a3b8`.
}Ends the current rule block.
🏢Real-world
  • 1Target buttons/links/forms precisely without adding extra HTML.
  • 2Build reusable component classes instead of styling every tag globally.
Common Mistakes
  • 1Using IDs everywhere (high specificity, hard to override).
  • 2Writing overly long selectors that are fragile.
Best Practices
  • 1Prefer class selectors for components.
  • 2Keep specificity low; override by placing rules later or using a parent class.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css selectors class selector id selector attribute selector pseudo class
∙ Chapter 112

CSS Combinators (References)

Combinators select elements by relationship: descendant, child, adjacent sibling, general sibling.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-combinators.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.card a {Targets elements matching: .card a.
color:#00e5ffSets `color` to `#00e5ff`.
}Ends the current rule block.
ul > li {Targets elements matching: ul > li.
margin-top:6pxSets `margin-top` to `6px`.
}Ends the current rule block.
h2 + p {Targets elements matching: h2 + p.
margin-top:0Sets `margin-top` to `0`.
}Ends the current rule block.
🏢Real-world
  • 1Target buttons/links/forms precisely without adding extra HTML.
  • 2Build reusable component classes instead of styling every tag globally.
Common Mistakes
  • 1Using IDs everywhere (high specificity, hard to override).
  • 2Writing overly long selectors that are fragile.
Best Practices
  • 1Prefer class selectors for components.
  • 2Keep specificity low; override by placing rules later or using a parent class.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css combinators descendant selector child selector adjacent sibling general sibling
∙ Chapter 113

CSS Pseudo-classes (References)

Pseudo-classes target states: :hover, :focus-visible, :checked, :nth-child() and more.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-pseudo-classes.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
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:800Sets `font-weight` to `800`.
}Ends the current rule block.
li:nth-child(odd) {Targets elements matching: li:nth-child(odd).
opacity:.9Sets `opacity` to `.9`.
}Ends the current rule block.
🏢Real-world
  • 1Target buttons/links/forms precisely without adding extra HTML.
  • 2Build reusable component classes instead of styling every tag globally.
Common Mistakes
  • 1Using IDs everywhere (high specificity, hard to override).
  • 2Writing overly long selectors that are fragile.
Best Practices
  • 1Prefer class selectors for components.
  • 2Keep specificity low; override by placing rules later or using a parent class.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

pseudo class hover focus visible nth-child checked
∙ Chapter 114

CSS Pseudo-elements (References)

Pseudo-elements style parts of elements: ::before, ::after, ::first-line, ::marker.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-pseudo-elements.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.pill::before {Targets elements matching: .pill::before.
content:"#";Sets `content` to `"#"`.
opacity:.7;Sets `opacity` to `.7`.
margin-right:6pxSets `margin-right` to `6px`.
}Ends the current rule block.
li::marker {Targets elements matching: li::marker.
color:#ff4081Sets `color` to `#ff4081`.
}Ends the current rule block.
🏢Real-world
  • 1Target buttons/links/forms precisely without adding extra HTML.
  • 2Build reusable component classes instead of styling every tag globally.
Common Mistakes
  • 1Using IDs everywhere (high specificity, hard to override).
  • 2Writing overly long selectors that are fragile.
Best Practices
  • 1Prefer class selectors for components.
  • 2Keep specificity low; override by placing rules later or using a parent class.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

pseudo element before after marker first-line
∙ Chapter 115

CSS At-rules

At-rules begin with @ and control features like media queries, keyframes, supports, and fonts.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-at-rules.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
@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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css at-rules @media @keyframes @supports @font-face
∙ Chapter 116

CSS Functions

Functions like var(), calc(), clamp(), rgb(), and url() build powerful values.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-functions.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css functions var calc clamp rgb
∙ Chapter 117

CSS Reference Aural

Aural/speech CSS was experimental and is largely obsolete; focus on modern accessibility instead.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-reference-aural.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

aural css speech css obsolete css accessibility css history
∙ Chapter 118

CSS Web Safe Fonts

Web-safe fonts work everywhere. Use them as fallbacks even with custom fonts.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-web-safe-fonts.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
body {Targets elements matching: body.
font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serifSets `font-family` to `system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

web safe fonts font stack fallback fonts typography css
∙ Chapter 119

CSS Animatable

Not every property animates smoothly. Prefer transform/opacity for performance.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-animatable.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.card {Targets elements matching: .card.
transition:transform .2s ease, opacity .2s easeSets `transition` to `transform .2s ease, opacity .2s ease`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

animatable properties css animation performance transform opacity jank
∙ Chapter 120

CSS Units (References)

Use px for fixed sizes, rem for scalable typography, and %/vw for responsive layouts.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-units.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
:root {Targets elements matching: :root.
font-size:16pxSets `font-size` to `16px`.
}Ends the current rule block.
h1 {Targets elements matching: h1.
font-size:2remSets `font-size` to `2rem`.
}Ends the current rule block.
.box {Targets elements matching: .box.
width:50vw;Sets `width` to `50vw`.
max-width:720pxSets `max-width` to `720px`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css units px rem em vw
∙ Chapter 121

CSS PX-EM Converter

Convert px to em/rem: em = px / baseFontSize (usually 16).

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-px-em-converter.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

px to em px to rem css converter typography units
∙ Chapter 122

CSS Colors (References)

CSS supports named colors, hex, rgb/rgba, hsl/hsla, and modern color functions.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-colors.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.badge {Targets elements matching: .badge.
color:#0f172a;Sets `color` to `#0f172a`.
background:#ffd54fSets `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.
🏢Real-world
  • 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
  • 2Gradients and shadows can replace image assets for simple UI depth.
Common Mistakes
  • 1Low contrast text (hard to read).
  • 2Overusing heavy shadows and making UI look blurry.
Best Practices
  • 1Aim for readable contrast; test quickly by lowering screen brightness.
  • 2Prefer soft, low-opacity shadows and avoid stacking many effects.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css colors hex color rgb hsl rgba
∙ Chapter 123

CSS Color Values

Color values include hex, rgb/rgba, hsl/hsla, and named colors.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-color-values.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
.a {Targets elements matching: .a.
color:#00e5ffSets `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.
🏢Real-world
  • 1Create visual hierarchy: backgrounds, contrast, and subtle shadows.
  • 2Gradients and shadows can replace image assets for simple UI depth.
Common Mistakes
  • 1Low contrast text (hard to read).
  • 2Overusing heavy shadows and making UI look blurry.
Best Practices
  • 1Aim for readable contrast; test quickly by lowering screen brightness.
  • 2Prefer soft, low-opacity shadows and avoid stacking many effects.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css color values hex rgb hsl rgba
∙ Chapter 124

CSS Default Values

Browsers apply default styles (user agent stylesheet). Reset/normalize can help consistency.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-default-values.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
body {Targets elements matching: body.
margin:0Sets `margin` to `0`.
}Ends the current rule block.
img {Targets elements matching: img.
max-width:100%;Sets `max-width` to `100%`.
height:autoSets `height` to `auto`.
}Ends the current rule block.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

css defaults user agent stylesheet normalize reset browser default
∙ Chapter 125

CSS Browser Support

Use progressive enhancement: ship a baseline, then add modern features with fallbacks.

📝Syntax
selector {
  property: value;
}
Example (Edit & Run)

Edit the example below. Keep the <style> section and experiment.

css-browser-support.html
📝 Edit Code
👁 Live Preview
💡 Tip: start by changing colors, spacing, and then layout properties.
🔍Line-by-line
LineMeaning
@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.
🏢Real-world
  • 1UI components (buttons, cards, navbars) use these rules daily.
Common Mistakes
  • 1Small typos (missing `;`, wrong selector) are the #1 reason CSS "does not work".
Best Practices
  • 1Use DevTools: inspect the element and check which rule wins.
📖Summary & Practice
  • 1Understand the core concept, then practice it in a small UI component.
  • 2Prefer simple rules that are easy to override and reuse.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 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.
📈SEO

Keywords (topic intent):

browser support progressive enhancement fallback @supports compatibility
PreviousBack to Home
🎉 CSS Tutorial Complete (125 topics)!
Next UpJavaScript Basics →