All subjects · Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript
Images on web pages: formats, size, resolution and alt text
Edexcel IAL Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript
Images must be the right format and size, keep their proportions, sit in the right place and have alt text (spec 7.3.1).
The img element
<img src="images/pool.jpg" alt="Children having a swimming lesson in the main pool" width="300" height="200">- src gives the path to the image file (relative in the exam).
- alt gives a text alternative. Screen readers read it out, it is shown if the image fails to load, and search engines index it. Describe what the image shows or does. A purely decorative image gets an empty alt (
alt="") so screen readers skip it. - width and height (in pixels) reserve space, so the page does not jump while the image loads.
File formats
| Format | Best for | Notes |
|---|---|---|
| JPEG (.jpg) | Photographs | Lossy compression: small files, many colours, no transparency |
| PNG (.png) | Logos, icons, screenshots, images needing transparency | Lossless; supports transparency; larger files for photos |
| GIF (.gif) | Simple animations, very simple graphics | Only 256 colours; supports animation and simple transparency |
| SVG (.svg) | Logos and icons that must scale | Vector: stays sharp at any size |
| WebP (.webp) | Photos and graphics on modern sites | Smaller files than JPEG or PNG at similar quality |
Size, resolution and proportions
Screens display images in pixels, so prepare images at the size they will be shown: a 4000-pixel-wide photo shown 300 pixels wide wastes download time. Print resolution (dots per inch) does not matter on screen; the pixel dimensions do.
To retain proportions (the aspect ratio), change width and height by the same factor, or set only one of them and let the other be automatic. In CSS: width: 100%; height: auto;.
Example: a 1200 x 800 image shown 300 pixels wide must be 200 pixels high, because 800 / 1200 x 300 = 200.
Positioning an image (floating it beside text, centring it) is done with CSS, covered in the CSS lessons.
Worked example
A photo is 1200 pixels wide and 800 pixels high. It must be shown 300 pixels wide without distortion. What height should be set?
- Scale factor = 300 / 1200 = 0.25
- Height = 800 x 0.25 = 200
Answer: 200 pixels (or set height to auto)
Check yourself
- An image is 800 pixels wide and 600 pixels high. It is resized to 200 pixels wide with its proportions kept. What is the new height in pixels?
Show answer
150 pixels. Scale factor 200 / 800 = 0.25; 600 x 0.25 = 150.
- Which format is best for a full-colour company logo with sharp edges and a soft, semi-transparent shadow?
- JPEG
- GIF
- PNG
- BMP
Show answer
PNG. PNG is lossless, keeps millions of colours and supports partial transparency. JPEG has no transparency and blurs sharp edges; GIF has only 256 colours and on-or-off transparency.
- Give two reasons why every content image should have an alt attribute.
Show answer
A screen reader reads the alt text to blind users, and the text is displayed if the image fails to load.. Alt text makes the image accessible to screen reader users, appears when the image cannot be shown, and helps search engines understand the image.
- What should the alt attribute be for a purely decorative border image?
- The file name of the image
- The word image
- It should be left out completely
- An empty value: alt=""
Show answer
An empty value: alt="". An empty alt tells screen readers to skip the image. Leaving alt out makes some screen readers read the file name.
- A gallery of holiday photographs must load quickly. Which format suits the photos best?
- GIF
- JPEG
- PNG-8 with 256 colours
- SVG
Show answer
JPEG. JPEG's lossy compression gives small files for photographs with many colours.
- Why should an image be resized before it is put on a web page instead of being shown smaller using width and height?
- Browsers cannot display large images
- Resized images get alt text automatically
- The width attribute only works on PNG files
- A large file still downloads in full, wasting time and data
Show answer
A large file still downloads in full, wasting time and data. The browser downloads the whole file whatever size it is displayed at, so oversized images slow the page.
Sources
- Pearson Edexcel International Advanced Subsidiary/Advanced Level in Information Technology specification (first teaching 2018), Unit 2 Topics 7 to 11
- Pearson qualifications: Edexcel International Advanced Level Information Technology (2018)
Last updated 8 November 2026. Spotted a mistake? Tell us.