Welcome to the class notebook. Each lesson below keeps to the same shape: a short explanation, the terms worth remembering, and a worked example you can copy into your own page. Use the index on the left to jump straight to a topic.
How the web works
A web page is just a text file that a browser knows how to read. When you type an address, your browser asks a server for that file. The server sends back the text, and the browser paints it onto the screen. Nothing more mysterious than that — which is good news, because it means you can build a page with tools you already own.
- Browser
- The program that reads your files and draws the page.
- Server
- The computer that stores the files and hands them out.
- URL
- The address that tells the browser where to look.
Your first HTML page
HTML describes the structure of a page. A heading is a heading, a paragraph is a paragraph, and a list is a list, whatever it happens to look like. Tags come in pairs: an opening tag announces an element, and a closing tag, with a forward slash, ends it.
Example — a very small page
<h1>Hello</h1>
<p>My name is Ada.</p>
<ul>
<li>Coffee</li>
<li>Code</li>
</ul>
Styling with CSS
CSS decides how those elements look. A rule has two
parts: a selector that chooses which elements to
style, and a set of declarations inside curly
braces that say what to do. Keep every rule in one file named
style.css and link it from the head of your page.
Example — colour every paragraph
p {
color: #2b2f36;
line-height: 1.7;
}
The box model
Every element on the page is a rectangle, and every rectangle has four layers. Understanding them is the single biggest step towards laying a page out with confidence.
- Content — the text or image itself.
- Padding — the breathing room inside the border.
- Border — the line drawn around the padding.
- Margin — the empty space outside the border.
Change the padding and you push the content around inside the box. Change the margin and you nudge the whole box.
Lists & structure
Lists are the quiet workhorses of a web page. The sidebar on
the left of this layout is an ordered list of links; the menu at
the top is a row of plain links. Number your steps with
<ol> and collect items with
<ul>.
- Write the content in index.html.
- Link the stylesheet in the page head.
- Style the page, one section at a time.
- Resize the window to check it still reads well.
That last point matters: a good page is comfortable on a wide screen and on a phone. Try dragging the corner of your browser now — the index will move above the notes and the text will make room for itself.