Skip to content
IGCSE·Tuition
ICT · Lesson

Size an image with meaningful alternative text

The picture appears on your page, but it is stretched, and the description you typed says only image.

On this page
  1. What does the img element need?
  2. How do you set the size step by step?
  3. Worked example
  4. The mistake to watch for
  5. Check yourself
  6. Where this leads next

Placing an image on a page needs three things: the right path, a size that keeps its proportions, and alternative text that describes it. This skill appears in web tasks with supplied pictures, and it joins the proportion work from resizing an image without changing its aspect ratio to the paths in relative links.

What does the img element need?

<img src="images/hall.jpg" width="300" height="200" alt="Club members setting up chairs in the school hall">
  • src is the path to the file.
  • width and height are the displayed size in pixels.
  • alt is the text description.

The img element has no closing tag.

How do you set the size step by step?

  1. Find the original size from the file properties, written width × height.
  2. Decide the new width from the brief.
  3. Calculate the scale factor = new width ÷ original width.
  4. Calculate the new height = original height × scale factor.
  5. Check the ratio: new width ÷ new height should equal the original width ÷ original height.
  6. Write the alt text after you have looked at what the picture shows.

Worked example

An invented photo hall.jpg is 1200 × 800 pixels. The brief says it must be 300 pixels wide.

Step 1: scale factor = 300 ÷ 1200 = 0.25.

Step 2: new height = 800 × 0.25 = 200.

Step 3: check: 300 ÷ 200 = 1.5, and 1200 ÷ 800 = 1.5. The ratio matches.

Step 4: the picture shows club members arranging chairs. The code is:

<img src="images/hall.jpg" width="300" height="200" alt="Club members arranging chairs in the school hall">

The mistake to watch for

A common slip is to type both numbers from the brief without calculating.

<img src="images/hall.jpg" width="300" height="300" alt="image">

There are two faults. The height 300 does not follow the ratio: 300 ÷ 300 = 1, not 1.5, so the hall looks tall and narrow. And “image” tells a screen reader user nothing.

The correction is height 200, and a description such as “Club members arranging chairs in the school hall”. If a brief fixes only the width, you may also leave out the height and let the browser keep the ratio.

Check yourself

1. An image is 900 × 600. It must be 450 wide. What height keeps its proportions?

Show answer

Scale factor = 450 ÷ 900 = 0.5. Height = 600 × 0.5 = 300.

2. An image is 1600 × 1000 and must be 400 wide. Give the new height.

Show answer

Scale factor = 400 ÷ 1600 = 0.25. Height = 1000 × 0.25 = 250.

3. Which alt text is better for a photo of a hand-painted poster: alt="poster1.jpg" or alt="Hand-painted poster announcing the photo club exhibition"?

Show answer

The second. It says what the picture shows and why it is on the page. The first only repeats the file name.

Where this leads next

Next, check whether a page uses tables and layout features the way a brief asks in Check required table or layout features without obsolete assumptions. Return to the module guide and confirm your sizes with the practical task and evidence checker.

Students can calculate the size correctly and still forget the description, which a marker looks for separately. Our teachers go through both in online one-to-one ICT tuition.

Questions people ask

What is alternative text for?

Alternative text, the alt attribute, describes the picture in words. It is read aloud by screen readers, and it is shown if the image fails to load. A good description says what the picture shows and why it is there, in a short phrase, not the file name.

How do I keep an image in proportion on a web page?

Work out the scale factor from the new width divided by the original width, then multiply the original height by the same factor. Or set only the width and let the height follow. Entering both numbers without checking the ratio is what distorts a picture.

Should every image have alt text?

Every img element needs an alt attribute. A picture that adds meaning needs a real description. A picture used only for decoration can take an empty alt, written as alt with two quotation marks and nothing between them, so a screen reader skips it. Follow what the task asks.

Updated:

Your next step

If your images keep coming out squashed or marked down, a one-to-one teacher can check your sizes and wording against the brief and show how to fix each one.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parents: enquire here

  • 9,000+ students helped through our service
  • 9+ years helping IGCSE students