ENES

CSS

The language that decides how a web page looks: colors, fonts, spacing, layout.

The same plain web page shown twice: before CSS it is plain text, after a few CSS rules it has colors, a header and a card layout

CSS (Cascading Style Sheets) is the language that styles web pages. HTML says "this is a heading, this is a list"; CSS says "headings are dark blue and large, the list sits in a column on the right, and on a phone everything stacks". A CSS file is a list of rules, each one picking some elements and setting properties, like h1 { color: navy; }.

Keeping looks separate from content is the big idea. The same HTML can look completely different with another stylesheet, and one stylesheet can restyle thousands of pages at once. It also lets a single site adapt to a big monitor, a phone, a printer or a dark mode setting without rewriting the content.

The "cascading" part is how CSS settles conflicts. When several rules apply to the same element, the more specific one wins, and among equals the later one wins. That makes it powerful and, for beginners, sometimes puzzling: a color that "will not change" is usually being overridden by another rule somewhere else.

Keep in mind

Go deeper

Related terms

More in Software