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

Images and stylesheets: the near-misses

Exam practicePresent ▶

What this lesson covers

12.1 Place and resize images

Cambridge IGCSE ICT 0417 · Topic 12: Images

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

  • Resize an image to the stated size, keeping the aspect ratio unless told otherwise.
  • Use hex colour codes correctly in a stylesheet.
  • Explain why an absolute path to a local file breaks when the site is moved.
  • Correct a set of near-misses: wrong sizes, missing hex, unattached stylesheets and broken links.

Success criteria

  • I can work out the new height of an image when I change its width.
  • I can spot a stylesheet that is not attached, and fix it.
  • I can fix every near-miss in the set.
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.
  • 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.

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.
Colour depth
The number of bits used to store the colour of one pixel.
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.

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.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.