Skills / Web pages with HTML and CSS / How a web page is made

Web pages with HTML and CSS, lesson 1 of 8

How a web page is made

Every web page is a text file written in HTML (HyperText Markup Language). HTML does not decide how things look. It says what each part *is*: a heading, a paragraph, a link, an image, a list.

HTML is made of elements. Most have an opening tag and a closing tag around some content:

  • <h1>Fresh bread daily</h1> is the main heading of the page
  • <p>Open from 7am.</p> is a paragraph
  • <a href="/menu">See the menu</a> is a link
  • <img src="loaf.jpg" alt="A sourdough loaf"> is an image (it has no closing tag; the alt text describes it for people who cannot see it)

A full page has a fixed outline: a <head> with the title and settings, and a <body> with everything the visitor sees.

CSS (Cascading Style Sheets) is a second file of rules that say how elements look. A rule picks elements with a selector, then sets properties: h1 { color: brown; font-size: 40px; } makes every main heading brown and large.

Keeping structure (HTML) and looks (CSS) apart is the whole idea. You can restyle a site completely by changing only the CSS, and search engines and screen readers understand the page because the HTML says what each part means.

The browser reads the HTML, applies the CSS, and draws the result. Right-click any page and choose Inspect to see both, live.

Try it: Open any website you like, right-click a heading and choose Inspect. Find the HTML tag for that heading and one CSS property that styles it.

Check yourself

1. What is HTML responsible for?

2. What does the alt text on an image do?

3. In the CSS rule h1 { color: brown; }, what is h1?