All subjects · Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

Audio, video and inline frames

Edexcel IAL Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

Media elements embed sound and video, with controls and alternative file formats; inline frames embed content from other websites (spec 7.3.5 and 7.3.6).

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

Audio and video

<video width="480" height="270" controls poster="images/poster.jpg">
  <source src="media/tour.mp4" type="video/mp4">
  <source src="media/tour.webm" type="video/webm">
  Your browser does not support the video element.
</video>

<audio controls>
  <source src="media/welcome.mp3" type="audio/mpeg">
  <source src="media/welcome.ogg" type="audio/ogg">
  Your browser does not support the audio element.
</audio>

Attributes and controls

AttributeEffect
controlsShows the browser's play, pause, volume and timeline controls
autoplayStarts playing as soon as possible (most browsers only allow this if muted)
mutedStarts with the sound off
loopStarts again when it ends
poster (video)Image shown before the video plays
preloadHints how much to download in advance: none, metadata or auto
width, height (video)Size of the video area

controls, autoplay, muted and loop are Boolean attributes

Customising controls

To give media your own buttons, leave out controls and use JavaScript with the media element's methods and properties:

const vid = document.getElementById("tour");
document.getElementById("playBtn").addEventListener("click", function () {
  if (vid.paused) {
    vid.play();
  } else {
    vid.pause();
  }
});

Other properties include currentTime, volume (0 to 1) and muted. For accessibility, captions can be added with a <track> element (kind="captions").

Inline frames (7.3.6)

An <iframe> displays another web page inside the current one: a map, a video from a video-sharing site, a booking widget or a news feed.

<iframe src="https://www.example.com/map" width="600" height="400" title="Map showing the sports centre"></iframe>

Worked example

A video plays in Chrome but not in another browser, which does not support MP4. How can the page support both browsers?

  1. Leave out src on the video element.
  2. Add two source elements, one MP4 and one WebM, each with its type.
  3. The browser plays the first format it supports.

Answer: Provide the video in several formats with source elements inside the video element.

Key idea: audio and video take controls, autoplay, muted, loop (and poster for video); several source elements give alternative formats and the browser uses the first it supports; JavaScript play() and pause() build custom controls; iframe embeds another page, with a title.

Check yourself

  1. Why might a video element contain two source elements?
    • To play two videos at the same time
    • To show a poster and a video
    • To add subtitles in two languages
    • To give the same video in two formats, so each browser can play one it supports
    Show answer

    To give the same video in two formats, so each browser can play one it supports. The browser picks the first source it can play.

  2. Which Boolean attribute makes the browser show play, pause and volume buttons on an audio element? Type the attribute name.
    Show answer

    controls. controls displays the browser's built-in media controls.

  3. A video has sources in this order: WebM, MP4, Ogg. A browser supports MP4 and WebM. Which file does it play?
    • The MP4 file
    • The Ogg file
    • It plays all three in turn
    • The WebM file
    Show answer

    The WebM file. The browser uses the first source it supports, which is the WebM file.

  4. What does the src attribute of an audio element specify?
    Show answer

    The location (path or URL) of the audio file to play.. src gives the location of the media file. Pearson's June 2025 report said vague answers did not earn the mark, so name both the location and the file.

  5. Which element embeds a map from another website inside a page?
    • `<embed-page>`
    • `<frame-src>`
    • `<iframe>`
    • `<link>`
    Show answer

    `<iframe>`. iframe (inline frame) displays another page inside the current one.

  6. Give one disadvantage of using an iframe to show content from another website.
    Show answer

    The page depends on the other website: if it is down or changes, the content will not appear.. The content is controlled by another site: it may be unavailable, change, slow the page, track users or refuse to be framed.

  7. A designer wants a background video to start automatically. Which pair of Boolean attributes do modern browsers require for autoplay to work?
    • autoplay and controls
    • loop and poster
    • autoplay and muted
    • preload and controls
    Show answer

    autoplay and muted. Most browsers block autoplay with sound, so autoplay needs muted.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.