Recent chats
ASKGEEZ Q&A GUIDETechnology & devices

How do I add captions and a transcript to a video in an HTML page?

Quick answer

Put a <track> element inside the <video> element to associate a synchronized captions file, and identify it with a language and a reader-friendly label. Keep the transcript as separate page content or link to it near the video. Captions and transcripts serve different purposes: captions are synchronized with playback, while a transcript can also describe important visual information. Check that both resources are findable and usable in your player.

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

What is the basic HTML pattern for adding both captions and a transcript?

Geez

Add the captions as a <track> inside the <video>, then provide the transcript separately in the page, usually immediately below the video. The kind identifies the track as captions; srclang identifies its language; and label gives people a recognizable track name. A transcript is not a second captions track: it is accompanying text that readers can read at their own pace. [S1]

Here is a starter pattern. Replace the bracketed values with your own file paths and language details:

<video controls>
  <source src="[video-file.mp4]" type="video/mp4">
  <track
    kind="captions"
    src="[captions-en.vtt]"
    srclang="en"
    label="English captions">
</video>

<section aria-labelledby="transcript-heading">
  <h2 id="transcript-heading">Video transcript</h2>
  <p>[Add the transcript text here.]</p>
</section>

The example associates an English captions file with the video and places a clearly headed transcript nearby. Keep the transcript heading and content in the page rather than treating the video’s controls as a substitute for it.

Follow-up question

What should go in the captions file, and how do I make the track identifiable?

Geez

Use a WebVTT file for the timed captions and point src to that file. The label should be a plain-language name readers can recognize, such as “English captions”; srclang should identify the captions’ language, such as en for English. The kind="captions" value communicates the track’s purpose. Captions can include dialogue and relevant sound information, not just spoken words. [S1]

For example, a track might look like this:

<track kind="captions" src="[captions-en.vtt]" srclang="en" label="English captions">

Make sure the label matches the actual track and that the referenced file is the intended captions file. The markup identifies and associates a resource; it does not establish that the captions are complete or correctly timed. Check the file’s contents and playback in your chosen browser or player.

Follow-up question

Where should I put the transcript, and should it repeat everything in the captions?

Geez

Put the transcript on the same page when practical, or place a clearly named link to it near the video. W3C WAI recommends making it easy to find from the media. [S2] A transcript should convey the spoken content and important visual information for people who cannot see the video; captions alone may leave out visual text or speaker identification. [S2]

A simple presentation could be:

<h2 id="transcript-heading">Video transcript</h2>
<p>[Speaker name]: [Spoken words.]</p>
<p>[On screen: a sign reads “[important visible text].”]</p>

Use the details that matter to understand this particular video. The transcript does not need to be synchronized with playback; that is the role of captions. WAI’s guidance also notes that applicable accessibility requirements vary with media type and conformance level, so this example alone does not determine whether a page meets a particular requirement. [S2]

Follow-up question

How can I check that visitors can find and use both resources?

Geez

Check the page as a reader would: find the video, locate its captions track, and find the transcript without searching elsewhere. Confirm the track label is meaningful, the language is correct, and the referenced file is the one you intended. Then play the video and check that captions appear in sync and include relevant sound information. Finally, read the transcript against the video for spoken content, speaker identification where useful, and important visual information.

A successful association in the HTML does not prove that every browser or player will present the track the same way. Playback and presentation can depend on the user agent and player. [S1] If a track does not appear as expected, check the file path and the player’s behavior; this guide does not establish compatibility for a particular setup.

A practical checklist

  • Place a <track> element inside the intended <video> element.

  • Set kind="captions" and provide the correct captions file path.

  • Set an accurate srclang value and a clear, matching label.

  • Put the transcript beneath the video or link to it clearly nearby.

  • Check that the transcript includes important visual information as well as spoken content.

  • Play the video to check caption timing and whether the track is presented as expected.

A few more useful answers

Can a transcript replace synchronized captions?

No. A transcript is accompanying text; a captions track is synchronized with playback. Provide the appropriate resource for each purpose. [S1]

Is an English captions label enough if the captions file is in another language?

No. Use a label and language value that accurately describe the actual track, so its identity is clear. [S1]

Does this HTML example prove the video meets every accessibility requirement?

No. The cited guidance distinguishes transcripts from captions and notes that applicable WCAG requirements vary by media type and conformance level. Check the requirements that apply to your specific media and context. [S2]

Sources

References used for this guide.

  1. [S1] MDN HTML Reference: The track Element
    developer.mozilla.org · Checked
  2. [S2] W3C WAI: Transcripts for Audio and Video
    w3.org · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work