All subjects · Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

HTML document structure: doctype, elements, attributes and the head

Edexcel IAL Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

Unit 2 is a 3-hour practical exam in which you write HTML, CSS and JavaScript in a plain text editor. Everything starts with a correctly structured HTML document (spec 7.1.1 to 7.1.3).

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

Elements, tags and attributes (7.1.1)

An HTML document is made of elements. Most elements have an opening tag, content and a closing tag. An attribute goes inside the opening tag and gives extra information as a name="value" pair.

<a href="prices.html">See our prices</a>

Here the element is the whole line, <a> is the opening tag, </a> is the closing tag, href="prices.html" is an attribute and 'See our prices' is the content. Some elements are empty (void) and have no closing tag or content, for example <br>, <img>, <meta>, <link>, <input> and <hr>.

The skeleton of every page

Every page has the same outline:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Opening times and prices for the Riverside Sports Centre">
    <title>Riverside Sports Centre</title>
    <link rel="stylesheet" href="css/style.css">
    <script src="js/main.js" defer></script>
  </head>
  <body>
    <h1>Riverside Sports Centre</h1>
    <p>Open every day from 7am.</p>
  </body>
</html>

Language declaration (7.1.2)

The lang="en" attribute on <html> declares the language of the page content. Screen readers use it to choose the right pronunciation, browsers use it for spelling checks, hyphenation and translation offers, and search engines use it to serve the page to users of that language. A part of the page in another language can carry its own lang attribute, for example <p lang="fr">Bonjour</p>.

The head element (7.1.3)

The head contains metadata (data about the page), which is not displayed in the page itself:

Worked example

A student's page shows the text on the tab as 'Untitled', and accented letters display as strange symbols. Which two lines are missing from the head?

  1. The tab text comes from the title element, so add `<title>Riverside Sports Centre</title>`.
  2. Garbled symbols are an encoding problem, so add `<meta charset="utf-8">` as the first line in the head.

Answer: A title element and a meta charset element.

Key idea: Doctype first, then html (with lang), head (metadata: charset, viewport, title, links, scripts) and body (visible content). Elements are made of tags, content and attributes; void elements have no closing tag.

Check yourself

  1. What is the purpose of `<!DOCTYPE html>` at the start of a page?
    • It is the root element that contains the head and body
    • It sets the character encoding of the page
    • It tells the browser the document is HTML5 so it renders in standards mode
    • It links the page to its stylesheet
    Show answer

    It tells the browser the document is HTML5 so it renders in standards mode. The doctype is a declaration, not an element: it tells the browser which version of HTML to expect (HTML5), so it does not fall back to quirks mode.

  2. Which element in the head sets the text shown on the browser tab? Type the element name without angle brackets.
    Show answer

    title. The title element sets the tab text, the bookmark name and the heading of the search result.

  3. In `<img src="logo.png" alt="Riverside logo">`, what is `alt`?
    • A tag
    • An element
    • An attribute name
    • A content model
    Show answer

    An attribute name. alt is an attribute name; "Riverside logo" is its value. Attributes go inside the opening tag.

  4. Give one reason for adding `lang="en"` to the html element.
    Show answer

    Screen readers use it to pronounce the text correctly in the right language.. The language declaration helps screen readers pronounce the words, helps search engines match the page to users of that language and lets browsers offer translation, spelling checks and hyphenation.

  5. Which of these is a void (empty) element with no closing tag?
    • `<title>`
    • `<p>`
    • `<head>`
    • `<meta>`
    Show answer

    `<meta>`. meta has no content and no closing tag. title, p and head all need closing tags.

  6. Where should a `<link rel="stylesheet" href="style.css">` element go?
    • After the closing html tag
    • Inside the head element
    • Before the doctype
    • Inside a paragraph in the body
    Show answer

    Inside the head element. link is metadata, so it belongs in the head.

  7. What does `<meta name="viewport" content="width=device-width, initial-scale=1">` do?
    Show answer

    It makes the page width match the width of the device screen so it is not zoomed out on a phone.. It sets the layout width to the device width at 100% zoom. Without it, phones display a zoomed-out desktop-width page and media queries do not work as intended.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.