Published by Patrick Mutisya · 14 days ago
Be able to insert appropriate objects into a web page including text, images, sound clips, video (display controls, remove controls, autoplay), to adjust image or video size, aspect ratio and apply alternate text.
Text is added directly within HTML elements such as <p>, <h1>–<h6>, <li>, etc. No special attributes are required.
Images are embedded with the <img> element. Key attributes:
src – URL of the image file.alt – Alternative text for accessibility and when the image cannot be displayed.width and height – Pixel dimensions; preserve aspect ratio by specifying only one dimension or by using matching values.Example:
<img src="photo.jpg" alt="Student using a laptop" width="300">
Audio is added with the <audio> element. Important attributes:
src – URL of the audio file (or use a nested <source> element).controls – Displays playback controls.autoplay – Starts playback automatically when the page loads.loop – Repeats the audio continuously.muted – Starts the audio muted (useful with autoplay to avoid unexpected sound).Example with controls:
<audio src="lecture.mp3" controls>Your browser does not support the audio element.</audio>
Video is embedded using the <video> element. Core attributes:
src or nested <source> – URL of the video file.controls – Shows play, pause, volume, etc.autoplay – Begins playback automatically.loop – Replays the video when it ends.muted – Starts the video without sound.width and height – Define display size in pixels.poster – Image shown before playback starts.Examples:
<video src="demo.mp4" width="640" height="360" controls>Your browser does not support the video tag.</video>
<video src="background.mp4" width="800" height="450" autoplay muted loop>Your browser does not support the video tag.</video>
<video src="intro.mp4" width="720" height="405" controls autoplay>Your browser does not support the video tag.</video>
The aspect ratio of an image or video is the relationship between its width and height:
\$\text{Aspect Ratio} = \frac{\text{width}}{\text{height}}\$
To keep the original aspect ratio while resizing, specify only one dimension (width *or* height). The browser will calculate the other dimension automatically.
If both dimensions are set, the media may be stretched or squashed unless CSS is used (outside the scope of this note).
Alternate text (alt) is essential for:
Guidelines for good alt text:
| Object | HTML Tag | Key Attributes | Typical Example |
|---|---|---|---|
| Paragraph text | <p> | None (content only) | <p>This is a paragraph.</p> |
| Image | <img> | src, alt, width, height | <img src="photo.jpg" alt="Student using a laptop" width="300"> |
| Audio clip | <audio> | src, controls, autoplay, loop, muted | <audio src="lecture.mp3" controls>…</audio> |
| Video clip | <video> | src, controls, autoplay, loop, muted, width, height, poster | <video src="demo.mp4" width="640" height="360" controls>…</video> |
<img> with a meaningful alt attribute.controls unless the question specifies otherwise.