Learn CSS Online with a Free Interactive Editor
Learn CSS online with a free, beginner-friendly tutorial and a live CSS editor built into this page. Read a short lesson, edit real CSS classes, and watch the preview update instantly — no installation, no sign-up, nothing to download.
Learn CSS for Free: A Complete Beginner's Guide to CSS Classes
CSS (Cascading Style Sheets) is the language that controls how a web page looks — colors, spacing, fonts, layout, and everything else HTML doesn't handle on its own. If you want to learn CSS online, the quickest path is to stop reading about selectors and start writing them, which is exactly what the live editor above lets you do against a real component.
What a CSS class actually is
A CSS class is a label you attach to an HTML element with the class
attribute, so a style rule can target it. Write <div class="card"> in your HTML, then
.card { } in your CSS, and every element carrying that class picks up the styles inside the
curly braces. The same class can be reused on as many elements as you like, which is what makes classes the
backbone of almost every real stylesheet — far more common than styling by tag name or ID.
Selectors: how CSS finds what to style
A selector is the part of a rule before the curly braces, and it decides which elements the rule applies
to. An element selector like p matches every paragraph. A class selector like .card
matches anything with class="card". An ID selector like #header matches the one
element with that ID. You can also combine selectors — .card p targets paragraphs sitting
inside anything with the class card.
Common CSS properties at a glance
| Property | Controls |
|---|---|
color | Text color |
background | Background color or image |
margin / padding | Space outside / inside an element's border |
border | An element's outline and its style |
display | How an element takes up space (block, flex, grid...) |
font-size / font-family | Text size and typeface |
flex / grid-template-columns | Layout of child elements |
transition | Smooth animation between style changes |
For the complete, official property list, the MDN CSS reference is the resource most working developers keep open in another tab.
The cascade: why "cascading" is in the name
When more than one rule could apply to the same element, CSS has to decide which one wins. That decision comes down to specificity (an ID beats a class, a class beats a tag name) and source order (later rules win ties). Understanding the cascade is what turns confusing "why isn't my style applying" moments into predictable, fixable ones.
A simple order to learn CSS in
- Start with selectors and classes, plus colors, fonts, and basic text styling.
- Learn the box model — margin, border, padding, width, and height — since almost every layout bug traces back to it.
- Move on to
display,position, and then Flexbox for one-dimensional layouts. - Add CSS Grid for two-dimensional layouts, and media queries for responsive design.
- Finish with transitions, animations, and pseudo-classes like
:hoverfor polish.
Switch between the preview components above, tweak their classes in the live editor, then test yourself with the exercises and quiz below — that repetition is what makes CSS syntax stick.
Where CSS fits going forward
Once classes, the box model, and Flexbox feel natural, most people pick up CSS Grid and a preprocessor or utility framework out of convenience — but every one of those tools still compiles down to the plain CSS you're practicing here. Time spent understanding real CSS classes and selectors keeps paying off no matter which framework you use later.
CSS Exercises
Write a real CSS rule in each box, then check your answer. Everything runs in your browser — nothing is sent anywhere.
CSS Quiz
Ten questions to test what you know. Your best score is saved on this device.
Frequently Asked Questions
More Developer Tools
Other free editors from the same toolbox.