🎨
CSS Fundamentals
Level
8 lessons31 exercises~6hLearn CSS from scratch with 31 hands-on exercises and a live preview editor. Selectors, colors and units, the box model, typography, display and positioning, flexbox, backgrounds and borders, transitions, all runnable in your browser with instant visual feedback.
01. Selectors & Syntax
How a CSS rule is built and how to target elements.
The anatomy of a CSS rule
Every CSS rule has a selector and a declaration block. Inside the block you write property: value; pairs.
selector {
property: value;
}
The core selectors
- Type:
ptargets every paragraph. - Class:
.badgetargets elements withclass="badge". Reusable. - ID:
#titletargets the single element withid="title". Unique. - Grouping:
h1, h2applies the same rule to several selectors. - Descendant:
nav atargets links inside a nav.
Specificity in one line
When rules conflict, an ID beats a class, and a class beats a type selector. Keep selectors as simple as the job allows.
Exercises (4)
Type selector
●●●
Select every <p> element and set its color to red.
CSS
Previewlive
Related
courseJavaScript Fundamentals74 hands-on exercises to learn JavaScript from scratch. Variables, math, arrays, objects, classes, DOM manipulation, async programming and REST APIs, all runnable in your browser.courseHTML FundamentalsLearn HTML from scratch with 30 hands-on exercises and a live preview editor. Document structure, text, lists, links and images, tables, forms, semantic HTML and accessibility, all runnable in your brtoolClamp GeneratorGenerate responsive font-size clamp() CSS.toolViewport Unit ConverterConvert between px and viewport units (vw, vh, vmin, vmax, dvh, svh, lvh, container query units). Includes batch conversion and fluid clamp() generator.
Free forever, no ads, no tracking. Support the project