Skip to the page
Year 11 · ICT · Spring 1 · Paper 3 practice: spreadsheets and websites

Website authoring under time

Exam practicePresent ▶

What this lesson covers

21.2b HTML body: text, tables and media

Cambridge IGCSE ICT 0417 · Topic 21: Website authoring · Paper 3

21.2c Hyperlinks and file paths

Cambridge IGCSE ICT 0417 · Topic 21: Website authoring · Paper 3

21.3a CSS: rules, classes, backgrounds and fonts

Cambridge IGCSE ICT 0417 · Topic 21: Website authoring · Paper 3

You will learn to

  • Use HTML to mark up headings, lists, a table and images with alt text and sizes.
  • Create hyperlinks with relative paths, and links that open in a new window.
  • Attach an external stylesheet with a relative path.
  • Use the mark scheme to mark your website task and log the lost marks.

Success criteria

  • I can build the page so it matches the specification.
  • I can test every link and show that it works.
  • I can show evidence of my HTML and my stylesheet.
The syllabus points for these sections
  • Mark up headings, paragraphs and ordered and unordered lists.
  • Group content with div elements and classes.
  • Build tables with th, td, rowspan and colspan, and set sizes in pixels or %.
  • Insert images, sound and video with alt text, sizes and controls.
  • Create bookmarks with id and link to them on the same page or another page.
  • Link to local pages, external URLs and email addresses.
  • Open links in a new window or a named window.
  • Explain relative and absolute paths, and why absolute paths to local files must not be used.
  • Write CSS rules with selectors, properties, values and comments.
  • Use inline styles and external stylesheets, and attach a stylesheet with a relative path.
  • Create and apply classes.
  • Set background colours and images.
  • Set font family with a generic fallback, size, colour, alignment, bold and italic.

Key words

Say each word, then read what it means. Every one is in the glossary too.

HTML
HyperText Markup Language: the language of the content layer of a web page.
CSS
Cascading Style Sheets: the language of the presentation layer, which sets how a page looks.
Tag
A word in angle brackets, such as `<p>`, that marks the start or end of an element.
Attribute
Extra information inside an opening tag, written name="value", such as src or alt.
Head
The part of a page holding information about it: title, meta tags, stylesheet links.
External stylesheet
A separate .css file attached to pages with the link element.
Inline style
CSS written in a style attribute inside one tag; it affects only that element.
Class
A label given to elements with the class attribute so CSS can style them as a group.
Selector
The part of a CSS rule that says which elements it styles, such as h1 or .note.
Generic font family
A fallback type of font (serif, sans-serif, monospace) used if named fonts are missing.
Bookmark
A named place on a page, made with an id, that a hyperlink can jump to.
Hyperlink
Clickable text or an image that goes to another place, made with the a tag.
Relative path
A file location described from the current file's folder, such as images/logo.png.
Absolute path
A full file location from the very start, such as a full URL or C:/...
Target
The attribute that sets which window a link opens in, such as _blank.
colspan / rowspan
Attributes that make a table cell stretch across columns or down rows.
Padding
The space inside an element or cell between its border and its content.
Alt text
Alternative text for an image, read by screen readers and shown if the image fails.

The explanation

Read it here, or open the study page below to go one step at a time with things to try.

21.2b HTML body: text, tables and media

Headings and paragraphs

`<h1>` is the main heading. `<h2>` is a subheading. `<h3>` is a heading inside an h2 section.

`<p>` is a paragraph. The browser adds space before and after it.

Use headings in order. Choose the tag for what the text is, not for how big it looks. CSS controls the size.

<h1>Café Retiro</h1>
<h2>Breakfast</h2>
<h3>Served until 12:00</h3>
<p>Fresh coffee, toast with tomato and olive oil, and homemade cakes.</p>
?Why?

Search engines and screen readers use headings to understand the page. A blind visitor can jump from heading to heading.

Ordered and unordered lists

An unordered list `<ul>` shows bullet points. Use it when order does not matter.

An ordered list `<ol>` shows numbers. Use it when order matters, such as steps or a top 3.

Each item goes in `<li>` (list item), inside the ul or ol.

<ul>
    <li>Café con leche</li>
    <li>Tostada con tomate</li>
    <li>Tarta de Santiago</li>
</ul>

<ol>
    <li>Choose a cake.</li>
    <li>Pay at the counter.</li>
    <li>Collect your order.</li>
</ol>
!Watch out

An li must be inside a ul or ol. A list item on its own is invalid HTML.

div and classes

A `<div>` is a box that groups other elements. On its own it changes nothing you can see.

A class is a label you give to elements with the class attribute. CSS can then style everything with that label.

Many elements can share one class. One element can have two classes, separated by a space.

<div class="offer">
    <h2>Today's offer</h2>
    <p>Coffee and a croissant for €3.20.</p>
    <p class="note">Until 11:00 only.</p>
</div>
/* every element with class="offer" */
.offer {
    background-color: #FFF3E0;
    border: 2px dashed #8B4513;
    padding: 10px;
}

.note {
    font-style: italic;
}
?Why?

A class lets you style some paragraphs differently without changing every paragraph.

Tables: table, tr, th, td

`<table>` starts a table. Each row is a `<tr>` (table row).

Inside a row, each cell is a `<td>` (table data) or a `<th>` (table header). Header cells are bold and centred by default.

Build a table row by row, from top to bottom. In each row, write the cells from left to right.

<table>
    <tr>
        <th>Drink</th>
        <th>Price</th>
    </tr>
    <tr>
        <td>Café con leche</td>
        <td>€1.80</td>
    </tr>
    <tr>
        <td>Té verde</td>
        <td>€1.60</td>
    </tr>
</table>
!Watch out

Every row must be closed with `</tr>` before the next `<tr>`. A missing closing tag can shift cells into the wrong row.

Merging cells: colspan and rowspan

colspan makes a cell stretch across several columns. colspan="3" fills 3 columns.

rowspan makes a cell stretch down several rows. rowspan="2" fills 2 rows.

When a cell spans, leave out the cells it covers. A row below a rowspan cell has one cell fewer.

DayOpenClose
Monday to Friday07:3020:00
Saturday09:00 (rowspan="2" covers Saturday and Sunday)21:00
Sunday(covered by the cell above)15:00
e.g.Example
Check by counting columns in each row: Row 1: one th with colspan 3 → 3 columns Row 2: 3 th → 3 Row 3: 3 td → 3 Row 4: Saturday + 09:00 (rowspan 2) + 21:00 → 3 Row 5: Sunday + (09:00 from above) + 15:00 → 3. Only 2 td are written.
<h2 id="hours">Opening hours</h2>
<table>
    <tr>
        <th colspan="3">Opening hours</th>
    </tr>
    <tr>
        <th>Day</th>
        <th>Open</th>
        <th>Close</th>
    </tr>
    <tr>
        <td>Monday to Friday</td>
        <td>07:30</td>
        <td>20:00</td>
    </tr>
    <tr>
        <td>Saturday</td>
        <td rowspan="2">09:00</td>
        <td>21:00</td>
    </tr>
    <tr>
        <td>Sunday</td>
        <td>15:00</td>
    </tr>
</table>
!Watch out

If row 5 also had a cell for 09:00, the row would have 4 columns and the table would stick out on the right.

Table and cell sizes

Set a width or height in pixels (px) for a fixed size, or in percent (%) for a share of the space.

width: 80% on a table makes it 80% of the page width, so it shrinks on a phone. 600px stays the same on every screen.

Use a style attribute in the tag, or a rule in the stylesheet. Older pages use width="80%" attributes. You may see them in source files.

<table style="width:80%">
    <tr>
        <th style="width:200px">Day</th>
        <td style="height:40px">Monday to Friday</td>
    </tr>
</table>
/* the same sizes, set in the stylesheet */
table {
    width: 80%;
}
th {
    width: 200px;
}
td {
    height: 40px;
}
!Watch out

Write the unit with no space: 200px, not 200 px or 200. Without a valid unit, the browser ignores the size.

Images

`<img>` inserts an image. It has no closing tag.

src is the relative path to the image file. alt is the alternative text, read aloud by screen readers and shown if the image cannot load.

width and height set the display size in pixels. Keep the aspect ratio (topic 12), or the image looks stretched.

e.g.Example
tarta.jpg is 600 × 400 pixels. The ratio is 600 ÷ 400 = 1.5. The question asks for a width of 300 pixels. Height = 300 ÷ 1.5 = 200 pixels. The ratio is kept. width="300" height="300" would squash the cake into a square.
<img src="images/tarta.jpg" alt="A slice of tarta de Santiago, an almond cake" width="300" height="200">
?Why?

Alt text makes the page accessible to blind visitors. The exam often asks for it and gives the exact words.

Sound and video

`<audio>` plays sound and `<video>` plays video. Put the file in a `<source>` tag inside them, with its type.

controls shows play, pause and volume buttons. autoplay starts the media when the page loads.

Video takes width and height in pixels. Text inside the element shows only if the browser cannot play the file.

<audio controls>
    <source src="media/jingle.mp3" type="audio/mpeg">
    Your browser cannot play this sound.
</audio>

<video width="480" height="270" controls autoplay muted>
    <source src="media/barista.mp4" type="video/mp4">
    Your browser cannot play this video.
</video>
?Why?

controls, autoplay and muted are true or false attributes. Writing the word switches them on. They need no value.

!Watch out

Most browsers block autoplay with sound. Add muted so autoplay works. Without controls, a visitor cannot pause the media.

21.2c Hyperlinks and file paths

Bookmarks and links to them

A bookmark is a named place on a page. Give any element an id: `<h2 id="hours">`.

A hyperlink uses the `<a>` (anchor) tag. Its href is where it goes. The text between the tags is what you click.

To jump to a bookmark, href is # then the id. To jump to a bookmark on another page, add the page name first.

<h1 id="top">Café Retiro</h1>
<a href="#hours">See our opening hours</a>

<h2 id="hours">Opening hours</h2>
<a href="#top">Back to top</a>

<!-- a bookmark called drinks on another page -->
<a href="menu.html#drinks">Drinks menu</a>
!Watch out

An id must be unique on the page and contain no spaces. It is case-sensitive: href="#Hours" will not find id="hours". Old pages use `<a name="hours">` instead of id.

Links to pages, websites and email

A local page is a page in your own site. Link to it with a relative path, such as menu.html.

An external website needs its full URL, starting with https://.

An email link uses mailto: then the address. Clicking it opens a new email to that address. You can add a subject with ?subject=.

<a href="menu.html">Our menu</a>

<a href="https://www.esmadrid.com">Visit Madrid</a>

<a href="mailto:orders@example.com">Email us</a>

<a href="mailto:orders@example.com?subject=Order">Order a cake</a>
!Watch out

href="www.esmadrid.com" without https:// does not go to the website. The browser looks for a file called www.esmadrid.com in your own folder.

Target windows: _blank, _self and named windows

The target attribute says where a link opens.

_blank opens a new window or tab. _self opens in the same window, which is the default.

A named window is any name you choose, such as target="menuwin". The first click opens a window with that name. Later links with the same target reuse it.

A target on a link overrides the base target in the head.

<a href="https://www.esmadrid.com" target="_blank">Visit Madrid</a>

<a href="menu.html" target="menuwin">Food menu</a>
<a href="drinks.html" target="menuwin">Drinks menu</a>
<!-- both open in the same window, called menuwin -->
?Why?

Opening external sites in a new window keeps your page open, so the visitor can come back to it.

!Watch out

_blank needs the underscore. target="blank" (no underscore) is treated as a named window called blank.

Relative and absolute paths

A path tells the browser where a file is.

A relative path starts from the folder of the current file. images/logo.png means "go into the images folder, then find logo.png".

../ means "go up one folder". From styles/cafe.css, the path to the beans image is ../images/beans.jpg.

An absolute path gives the full location from the very start, such as https://www.esmadrid.com/en or C:/Users/Lucia/Desktop/cafe/images/logo.png.

Try the toy: press From on one file and To on another, and read the relative path and why the absolute path breaks. Then switch to Quiz and write paths yourself. The toy's site uses css/style.css, but the rules are the same.

FromToRelative path
index.htmlmenu.htmlmenu.html
index.htmlimages/logo.pngimages/logo.png
index.htmlstyles/cafe.cssstyles/cafe.css
styles/cafe.cssimages/beans.jpg../images/beans.jpg
pages/about.htmlindex.html../index.html
!Watch out

Use forward slashes / in paths, not backslashes \. Match capitals exactly: on a web server Logo.PNG and logo.png are different files.

There is something to try for this step in the IGCSE library.

Why absolute paths to local files break

An absolute local path points to one place on one computer. C:/Users/Lucia/Desktop/... exists only on Lucía's computer.

When the folder is copied to a web server or an examiner's computer, that path no longer exists. Images vanish and the stylesheet is not applied.

Relative paths move with the folder, because they only describe how files sit compared with each other.

Absolute URLs are fine for external websites, because those addresses are the same from every computer.

e.g.Example
Lucía's page has `<img src="file:///C:/Users/Lucia/Desktop/cafe/images/logo.png">`. On her laptop: the logo shows. On the examiner's computer: there is no user called Lucia, so the logo is missing. With `<img src="images/logo.png">`: the logo shows on both.
!Watch out

Some editors insert absolute paths when you drag a file in. Always read the code and change it to a relative path.

21.3a CSS: rules, classes, backgrounds and fonts

How a CSS rule is written

A CSS rule has a selector (what to style), then curly brackets { } holding one or more declarations.

Each declaration is a property, a colon, a value and a semicolon: `color: #8B4513;`.

Comments go between /* and */. The browser ignores them. Use them to explain your styles.

/* Café Retiro: main headings */
h1 {
    color: #8B4513;
    text-align: center;
}

/* one rule for two selectors */
h2, h3 {
    color: #2E7D32;
}
!Watch out

CSS uses American spelling: color and center. colour and centre are not recognised, and the browser ignores that whole declaration.

Inline styles and external stylesheets

An inline style goes inside one tag, in a style attribute. It affects only that element.

An external stylesheet is a separate .css file attached with `<link>`. It can style every page.

An internal stylesheet sits in a `<style>` element in the head. It affects only that page.

Use external stylesheets for a whole site. Use inline styles only when the question asks, or for one exception.

<!-- inline: only this heading -->
<h1 style="color: #8B4513; text-align: center;">Café Retiro</h1>

<!-- in the head: internal and external -->
<link rel="stylesheet" href="styles/cafe.css">
<style>
    h2 {
        color: #1565C0;
    }
</style>
/* styles/cafe.css: CSS only, no <style> tags */
h2 {
    color: #2E7D32;
}
!Watch out

Never put `<style>` tags or any HTML inside a .css file. The browser stops reading the rule they break, and the styles fail.

Classes in CSS

A class selector starts with a full stop: .note styles every element with class="note".

p.note styles only paragraphs with that class. Other elements with class note are not affected.

A class name is case-sensitive and has no spaces. In the HTML it has no full stop.

e.g.Example
The first paragraph is brown and bold. The second has two classes, so it is brown, bold and italic.
<p class="price">Café con leche €1.80</p>
<p class="price note">Prices include VAT.</p>
.price {
    color: #8B4513;
    font-weight: bold;
}

p.note {
    font-style: italic;
}
!Watch out

Writing class=".price" in the HTML is wrong. The full stop belongs only in the CSS selector.

Backgrounds: colour and image

background-color fills an element with a colour. Colours can be names (white) or hex codes (#FDF6EC).

background-image uses url() with a relative path. The path starts from the CSS file, not from the HTML page.

background-repeat controls tiling: repeat, repeat-x, repeat-y or no-repeat.

body {
    background-color: #FDF6EC;
    background-image: url("../images/beans.jpg");
    background-repeat: repeat-x;
}

.offer {
    background-color: #FFF3E0;
}
?Why?

cafe.css is in the styles folder, so it goes up one folder (../) to reach images. Setting a background colour too means the page still looks right if the image fails to load.

!Watch out

A hex code has # and six hex digits (0–9, A–F). #FDF6E is only five digits and is ignored.

Fonts: family, size, colour, alignment, bold, italic

font-family lists fonts in order of preference, separated by commas. End with a generic family: serif, sans-serif or monospace.

The browser uses the first font it has. The generic family is the last resort, so the text still has the right kind of font.

font-size in px, pt, em or %. color sets the text colour. text-align is left, right, center or justify.

font-weight: bold makes text bold. font-style: italic makes it italic.

h1 {
    font-family: "Trebuchet MS", Helvetica, sans-serif;
    font-size: 32px;
    color: #8B4513;
    text-align: center;
    font-weight: bold;
}

p {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 16px;
    font-style: italic;
}
!Watch out

Put a font name in quotes when it has spaces ("Times New Roman"). Never put quotes round a generic family. "sans-serif" in quotes is treated as a font called sans-serif and does not work as a fallback.

Study it

Open the study page and go one step at a time.

The steps for this lesson

Try it

Check yourself

One question at a time. The reason shows after each answer.

Saved on this device.