CSS, short for Cascading Style Sheets, is the code that tells a browser how a web page should look: the colours, the fonts, the spacing, the layout, and how all of it rearranges on a phone. HTML supplies the content and its structure; CSS dresses it. Without CSS a browser falls back on its own plain default styles, which is why a page whose stylesheet fails to load turns into black text in one column. A business owner rarely writes CSS, yet it decides whether the site looks like the brand, whether it works on a small screen, and how quickly the first screen appears.
In short
- The code that controls how pages look.
- HTML holds the content, CSS the styling.
- It lets one site fit every screen.
- Bloated or pasted CSS slows and breaks pages.
What CSS does next to HTML
The two languages split the work cleanly. HTML says what each piece of a page is: a heading, a paragraph, an image, a button. CSS says how each piece should appear. Our page on HTML covers the structural half.
When somebody opens a page, the browser reads the HTML first and builds a model of it. It then gathers the CSS rules, works out which ones apply to which elements, and paints the result on the screen. The same HTML can look entirely different under two stylesheets, which is how a theme change can transform a site without altering a single word.
How a stylesheet is written
A stylesheet is a list of rules, and each rule has two parts. A selector names the elements to style, for instance every main heading or every button. A block of declarations then sets properties and values, such as a colour, a font size or the space around an element.
The word cascading describes what happens when several rules target the same thing. The browser follows a fixed order of precedence to decide which one wins, which is why an edit sometimes appears to do nothing: another rule, more specific or loaded later, is overriding it.
How CSS makes a site responsive
Responsive design is mostly CSS at work: flexible grids that stretch or stack, and media queries that apply different rules by screen size.
A row of three service boxes on a laptop becomes a single column on a phone because a media query tells it to. Font sizes, image widths and menu styles can all change at the same breakpoints. Our page on responsive design explains why adapting to a screen is not the same as working well on it.
Where your brand lives in the code
On a modern website the visual identity is written into the stylesheet.
- Colours. The exact brand colours, normally stored once as named values and reused throughout.
- Fonts. The typefaces, plus their sizes and weights for headings and body text.
- Spacing. The margins and padding that give each page its rhythm.
- Buttons and links. Their shape, their colour and how they change when a visitor hovers or taps.
- Breakpoints. The screen widths at which the layout rearranges itself.
A site where every page uses a slightly different shade usually has CSS that grew by patching, not planning.
The trouble with custom CSS
Most themes and site builders include a box for custom CSS, so small adjustments can be made without editing the theme files. WordPress, for example, offers an Additional CSS panel that overrides the current theme, and its documentation points out that those changes are tied to the theme. Switch themes and the adjustments either vanish or start styling things they were never written for.
The larger problem is accumulation. One rule pasted from a forum, another to correct a colour, a third left by a former freelancer: after a year nobody knows which lines still matter, and every theme update risks colliding with them.
How CSS affects speed
Stylesheets linked from a page block it from appearing until they arrive, because a browser would rather wait than paint an unstyled page.
Google’s guidance on Largest Contentful Paint, one of the three Core Web Vitals, notes that a large stylesheet can hold back the main content even after its image has finished loading. The target is for that content to appear within 2.5 seconds on at least 75 per cent of visits. The usual remedies:
- Remove unused rules. Themes and plugins often load styling a page never uses.
- Split critical and later styles. Rules for the first screen load immediately, and the rest follow.
- Minify and compress. Stripping spaces and compressing the file cuts what travels over the network.
- Keep inline styles small. Rules written into the page itself cannot be cached for the next visit.
Where CSS goes wrong
- Pasted fixes nobody documented. Lines from forums and past freelancers that fight every update.
- Too many plugins. Each can add its own stylesheet to every page, whether or not that page uses it.
- Hiding instead of removing. Content hidden with CSS still downloads and still weighs on the page.
- Fixed widths. Layouts that look right on one screen and spill sideways on a phone.
- Inconsistent values. Five near-identical greys where the brand specifies one.
Words you will hear
- Selector. The part of a rule that names which elements it styles.
- Media query. A condition that switches certain rules on at chosen screen sizes.
- Render blocking. Describes a file the browser must finish loading before it displays anything.
- Minification. Removing spaces and comments so a file downloads faster.
- Theme. A packaged design for a content system, built largely from stylesheets.
- Inline style. A rule attached directly to one element inside the page.
Ask whoever maintains your site for a list of every line in the custom CSS box and what each one does. Any line nobody can explain is worth removing before the next theme update removes it for you.
Questions we get
More about css
What is CSS?
What does CSS stand for?
What is the difference between HTML and CSS?
Does CSS affect SEO?
Is it safe to add custom CSS to my theme?
What is CSS3?
Can a business owner edit CSS?
Do it yourself
Guides on the same topic
Free step by step guides for owners doing the work themselves. No sign up and no email required.
Related terms
HTML
HTML stands for HyperText Markup Language, the code that gives every web page its structure. What it does, how it works with CSS and JavaScript, and why.
Responsive design
Responsive design means one site that rearranges itself to fit any screen. It is the default way sites are built, and being responsive does not make one fast.
Core Web Vitals
Core Web Vitals are three measurements Google takes of how a page behaves for real visitors: how fast it appears, how quickly it responds, how much it moves.