Learn/HTML, CSS & JS/1. Your first web page
Lesson 1 of 8
Sign in

HTML, CSS & JS, lesson 1

Your first web page

A web page is a text file written in HTML (HyperText Markup Language). HTML doesn't "run" like a program. It describes content: this is a heading, this is a paragraph, this is a link. The browser reads that description and draws the page.

Elements and tags

Content is wrapped in elements. Most elements have an opening tag, some content, and a closing tag with a slash:

  • <h1> is the most important heading on the page. There are six levels, <h1> to <h6>. Use them in order, like the outline of a document, not to make text bigger.
  • <p> is a paragraph. The browser adds space above and below it.

Elements can contain other elements. <strong> marks text as important and <em> adds emphasis:

Whitespace

The browser collapses spaces and line breaks in your HTML into a single space. Indenting your code makes it easier to read but doesn't change the page. To start a new paragraph, use a new .

2 exercises to try what you just read.

Exercise 1

A recipe card

Press Ctrl Enter or Check to test your code.

Exercise 2

Section headings

Press Ctrl Enter or Check to test your code.

<p>

The page skeleton

A complete HTML file has a <!doctype html> line, an <html> element, a <head> with information about the page (like its <title>), and a <body> with everything you see. In this course the editor fills in that skeleton for you, so you only write what goes inside <body>.

Further reading

  • MDN: Getting started with HTML
  • MDN: Headings and paragraphs

Write the start of a recipe page:

  1. An <h1> with the text Weekend pancakes.
  2. A paragraph (<p>) with the text Ready in 20 minutes.
  3. A second paragraph that contains the word simple wrapped in <strong>.

Below the main heading, add two sections of the page, each with an <h2> and a paragraph:

  • An <h2> saying Ingredients, followed by a <p> (any text).
  • An <h2> saying Steps, followed by a <p> (any text).

Keep the existing <h1>.

<h1>Weekend pancakes</h1>
<p>Fluffy, quick, and good with anything.</p>
<p>Rest the batter for <strong>ten minutes</strong>. It <em>really</em> helps.</p>