- Home
- /
- Tutorials
- /
- CSS Tutorial
- /
- What is CSS
CSS Introduction
What is CSS
Learn how CSS controls presentation, layout, spacing, typography, color, and responsive behavior while HTML continues to provide the document structure.
CSS is the language that decides how a web page looks: the colors, the fonts, the spacing, and where everything sits on the screen. HTML says what the content is; CSS says how it should appear.
CSS stands for Cascading Style Sheets. "Style sheet" is a set of style rules; "cascading" means the rules are applied in layers, so a general rule and a more specific one can both apply, and the more specific one wins. The shape of a rule is explained in CSS Syntax, and where to put it in How to Add CSS.
CSS Syntax
css
selector {
property: value;
}Every CSS rule picks some elements with a selector, then sets properties on them. For example, h1 { color: blue; } makes every main heading blue.
Some properties you will meet first
| Property | What it changes | Example |
|---|---|---|
| color | The text color | color: red; |
| background-color | The background | background-color: #f5f5f5; |
| font-size | How big the text is | font-size: 1.25rem; |
| margin | Space outside an element | margin: 1rem; |
| padding | Space inside an element | padding: 1rem; |
CSS is a constraint system
CSS does more than decorate individual elements. It resolves competing declarations, computes values, creates formatting contexts, and adapts the result to content, available space, device capabilities, and user preferences. Good CSS describes relationships and constraints instead of hard-coding one screenshot. The browser then performs the final layout for the actual document and environment.
CSS Example
html
<!DOCTYPE html>
<html>
<head>
<title>What is CSS Example</title>
<style>
body {
background-color: lightgray;
}
h1 {
color: blue;
}
p {
color: green;
font-size: 18px;
}
</style>
</head>
<body>
<h1>Welcome to CSS</h1>
<p>This is a paragraph styled using CSS.</p>
</body>
</html>The page gets a light grey background, a blue heading and a green paragraph in a larger font, all from a few lines of CSS in the <style> block.
Browser Support
Feature | Chrome | Edge | Firefox | Safari |
|---|---|---|---|---|
| Core CSS styling | 1 | 12 | 1 | 1 |
Versions show the first stable desktop release with unprefixed support. Data source: MDN Browser Compatibility Data 8.0.8.
Why CSS is separate from HTML
Keeping styles in their own file means one stylesheet can style every page of a site. Change the font once, and it changes everywhere. It also keeps the HTML clean and readable, and lets the same content look different on a phone, on a big screen and when printed.
What to learn next
Start with selectors, colors and the box model (margin, border, padding), then move on to layout with Flexbox and Grid. Each lesson in this tutorial builds on the one before.
Exercises: What is CSS
Your first rule
Write a rule that makes the main heading green.
The HTML your code works on
<h1>Plant Shop</h1>
<p class="intro">Fresh plants every week.</p>
<div class="card">Monstera</div>Result
