Skip to the page
Year 10 · ICT · Summer 2 · Website authoring and images; the Year 10 mock

Images and links

PracticalPresent ▶

What this lesson covers

12.1 Place and resize images

Cambridge IGCSE ICT 0417 · Topic 12: Images

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

You will learn to

  • Resize an image to a stated size while keeping its aspect ratio.
  • Insert an image with alt text and a set width and height.
  • Create links to another local page, an external URL and an email address.
  • Explain why relative paths must be used for local files.

Success criteria

  • I can work out the new height of an 800 × 600 image when its width becomes 400.
  • I can add an image with alt text that describes it.
  • I can make a mailto link and a link that opens in a new window.
The syllabus points for these sections
  • Place an image precisely, using alignment and text wrapping.
  • Explain what the aspect ratio of an image is.
  • Resize an image while keeping its aspect ratio.
  • Calculate the new height when you change the width.
  • Change the aspect ratio only when a task asks for it.
  • 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.

Key words

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

Aspect ratio
The width of an image compared with its height, such as 4:3.
Resize
Make an image bigger or smaller.
Text wrapping
How text flows around an image: square, tight, above and below, or in line.
Pixel
One tiny dot of colour; images are made of a grid of pixels.
Group
Join several objects so they move and resize as one.
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.
Class
A label given to elements with the class attribute so CSS can style them as a group.
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.

12.1 Place and resize images

What the exam task looks like

Cambridge image tasks are short and exact. Each part of the sentence is usually one mark.

A typical task: "Insert the image J2611logo.jpg at the top right of the first page. Resize it to 4 cm wide, maintaining its aspect ratio. Align the top of the image with the top margin."

Read the task three times. Underline the file name, the position, the size and any word like "maintain" or "do not distort".

e.g.Example
Task: Place the image to the right of the first paragraph. Resize it to 5 cm wide, maintaining the aspect ratio. Marks: right image (1), right of the first paragraph (1), 5 cm wide (1), not distorted (1).
?Why?

Examiners mark from a checklist. If you meet every item in the sentence, you get every mark. Missing one word, such as "right", loses that mark.

!Watch out

Many candidates insert the wrong file. Source folders often hold two similar files, for example `logo.jpg` and `logo2.jpg`. Check the file name before you click Insert.

Place the image precisely

Text wrapping decides how the text flows around an image. Cambridge names four kinds: above and below (top and bottom), square, tight, and in line with text.

In most word processors, select the image and open its layout or wrap options. Choose square so text sits beside the image in a neat rectangle.

Then align the image to the margin. Use the position or align options (align right, align top), not dragging by eye.

Wrap typeWhat the text doesGood for
In line with textThe image sits on a line like a big letterA picture on its own line
SquareText flows round a rectangle around the imagePhoto beside a paragraph
TightText follows the outline of the image itselfLogos with odd shapes
Above and belowText stops above the image and starts again below itWide images across the column
?Why?

Dragging by eye leaves the image a few millimetres off. The examiner checks that the edge lines up with the margin or the paragraph.

!Watch out

A common mark loss: the image sticks out past the margin into the white edge of the page. Always check the image's right edge sits exactly on the right margin.

Aspect ratio: the shape of the image

The aspect ratio is the width compared with the height. A photo 1600 pixels wide and 1200 pixels high has a ratio of 4:3.

If you change the width and height by the same factor, the ratio stays the same. The picture looks right.

If you change only one of them, the picture is distorted: squashed or stretched. Faces look fat or thin, and circles become ovals.

Try the toy. Change the width with Keep aspect ratio ON. Then turn it OFF and change the width again. Watch the round sun in the picture.

?Why?

Keeping the ratio keeps every shape in the picture correct. That is why tasks say "maintain the aspect ratio".

!Watch out

Dragging a side handle (the middle of an edge) changes only one dimension and distorts the image. Drag a corner handle, or better, type the size with the lock aspect ratio box ticked.

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

Calculate the new height

When you keep the aspect ratio, the new height depends on the new width.

New height = new width × original height ÷ original width.

Software does this for you when the aspect ratio lock is on. You still need the sum to check your result and for theory questions.

e.g.Example
An image is 8 cm wide and 6 cm high. The task says: resize it to 5 cm wide, maintaining the aspect ratio. New height = 5 × 6 ÷ 8 = 30 ÷ 8 = 3.75 cm So the image becomes 5 cm × 3.75 cm. The ratio is still 4:3.
?Why?

Both dimensions are multiplied by the same scale factor. Here the factor is 5 ÷ 8 = 0.625, and 6 × 0.625 = 3.75.

!Watch out

After typing the width, look at the height box. If it did not change, the lock was off. Undo and try again with the lock ticked.

Changing the aspect ratio on purpose

Sometimes a task gives both a width and a height. For example: "Resize the image to 3 cm high and 12 cm wide. You do not need to maintain the aspect ratio."

Untick the lock aspect ratio box first. Then type both numbers.

If you leave the lock on, the software will change your second number back. The image will be the wrong size.

e.g.Example
Banner image: 6 cm × 4 cm. Task: make it 12 cm wide and 3 cm high. Lock off. Width 12 cm, height 3 cm. The width doubled and the height went down by a quarter, so the picture is stretched. That is what the task asked for.
!Watch out

Only distort when told. In every other task, a distorted image loses the mark even if the width is correct.

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.

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.