Basic

The two languages on a page

A page is two things written in two languages. HTML says what the content is; CSS says how it should look. The confusion between them is the source of most layout trouble, because a developer reaching for CSS to describe meaning is fighting the wrong language.

What you will see

It looks like a heading and means nothing. A reader with a screen reader hears plain text, which is the failure this lesson is about.

About 2 min of reading

Try It

See the difference between meaning and style.

1

A heading by tag

Chapter one

Before you run it, say out loud what it will print. Then open the answer.

What it prints
Large bold text, and a screen reader announces it as a heading. The tag carries the meaning.
2

A heading by style only

Chapter one

Before you run it, say out loud what it will print. Then open the answer.

What it prints
It looks like a heading and means nothing. A reader with a screen reader hears plain text, which is the failure this lesson is about.

Data Flow

HTML names things, CSS styles them.
1 Write the content as HTML
↓
2 The browser builds a tree of elements
↓
3 CSS selects elements in that tree
↓
4 The selected elements get styles
Why this works
Structure before style

Write the HTML for the content, read it in the browser, and only then style it. A page with good structure and no CSS is readable, and that readable state is the thing you want to see before you start moving boxes.

One element, one job

A div that is a button is a bug. The element that already means button gives you the keyboard behaviour, the focus state, and the meaning for free. Reaching for a generic element to rebuild a real one is where accessibility quietly breaks.

Examples

HTML is the content

A heading is a heading because it is marked as one, not because it is large. That marking is what a screen reader, a search engine, and your own later code all rely on. Style is separate.

CSS is the appearance

CSS selects elements and describes how they look. It can change size, colour, and position, and it never changes what an element means. If you find yourself using CSS to say 'this is a heading', you have the wrong tool.

They meet at the selector

A CSS selector names HTML elements. That is the whole connection: HTML provides the things to point at, CSS points at them. When the two drift apart, the style silently stops applying, which is the most common bug in a stylesheet.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

Next Lesson
The elements you actually reach for
The elements you actually reach for →