What is CSS?
CSS decides how a website looks - colours, fonts, spacing, and layout.
Think of it like this
If HTML is the skeleton of a page, CSS is the clothes, haircut, and style. The same skeleton can look completely different depending on how it's dressed - and you can change the whole outfit without touching a single bone.
What's happening
Summary
CSS controls how a web page looks - colours, fonts, spacing, and layout - kept separate from the HTML content, so the same page can be completely restyled without rewriting it.
A Closer Look
CSS (Cascading Style Sheets) is the language used to control the appearance and layout of web pages. It works through rules: you pick which elements to style using a selector, then list how they should look. A rule like h1 { color: navy; font-size: 2rem; } means "make every main heading navy and twice the normal text size." One stylesheet can control every page on a site, so changing a single colour value can restyle hundreds of pages at once.
The "cascading" part describes what happens when rules disagree. If one rule says all text is black and another says links are blue, the browser follows a predictable order - more specific rules beat general ones, and later rules beat earlier ones - to decide which wins. CSS also handles responsive design: rules that only apply at certain screen sizes, which is how the same website can show three columns on a laptop and stack neatly into one column on a phone.
Before CSS existed, styling was crammed directly into HTML, with tags like <font> wrapped around individual pieces of text, so changing a site's colour scheme could mean editing every page by hand. CSS was proposed in 1994 by HΓ₯kon Wium Lie, who was working alongside Tim Berners-Lee at CERN, to move appearance out into its own separate file. Since then CSS has grown far beyond colours and fonts. Layout systems called Flexbox and Grid let designers arrange content into rows, columns and complex grids with just a few lines, and CSS can also produce smooth transitions and animations, such as a button gently changing colour when you hover over it.
Common Misconceptions
- CSS is not usually considered a programming language - it can do simple maths like working out widths, but it can't run step-by-step logic the way JavaScript can.
- CSS doesn't change what's on the page, only how it looks - that's still HTML's job.
- "Cascading" doesn't mean animations - it means styles can inherit and override each other in a predictable order.
Frequently asked questions
Should I learn HTML or CSS first?
HTML first, but not by much. CSS has nothing to style until there's HTML content on the page, so a few hours of basic HTML gives you something to practise on. After that, most beginners learn the two side by side, since every real web page uses both. Neither needs special software - a text editor and a web browser are enough to start.
What are CSS frameworks like Bootstrap and Tailwind?
They're collections of ready-made CSS that save you writing everything from scratch. Bootstrap provides pre-styled pieces such as buttons, menus and grids that you add to your HTML. Tailwind instead offers lots of small single-purpose classes, like one that adds padding or sets a colour, which you combine directly in your HTML. Both are still CSS underneath, so understanding plain CSS first makes them much easier to use.
Why does a website look different in different browsers?
Each browser has its own engine for reading HTML and CSS, and they don't always add new features at the same time or interpret every detail identically. Browsers also apply their own default styles, such as slightly different fonts or spacing, wherever a site hasn't set its own. The differences are far smaller than they once were, but web developers still test in several browsers to catch them.
How it connects
CSS always works alongside other technologies:
Try it yourself
Press F12 to open DevTools, then click the cursor icon and hover over any element on this page. You'll see its CSS styles listed on the right - try changing a colour value live.