Web Accessibility / Multimedia and Alternative Text

Adding Captions and Transcripts to Videos

Learn how to make your video content accessible to all users by adding captions and transcripts. This tutorial will teach you the HTML techniques for providing captions and transc…

Tutorial 2 of 5 5 resources in this section

Section overview

5 resources

Explores techniques for making multimedia content accessible using captions, transcripts, and alt text.

1. Introduction

This tutorial aims to guide you on how to make your video content more accessible by adding captions and transcripts using HTML. Captions and transcripts make your videos more accessible to a broader audience, especially those who are hard of hearing.

By the end of this tutorial, you will learn:
- How to add captions to videos using HTML
- How to add transcripts to videos using HTML

Prerequisites:
- Basic understanding of HTML (HyperText Markup Language)

2. Step-by-Step Guide

HTML Track Element:

HTML provides the <track> element which is used to specify text tracks for media elements (<audio> and <video>). The text tracks are specified as subtitles, captions, descriptions, chapters, or metadata. The source for the track file is given with the src attribute, and the kind of text track is specified with the kind attribute.

Adding Captions:

Captions are similar to dialogue-only subtitles, in addition to which they also include relevant parts of the soundtrack — representing background noises, phone rings, or other significant sounds.

To add captions to a video:

  1. Convert your captions into a WebVTT (.vtt) file. WebVTT stands for "Web Video Text Tracks". It is a format for captions, subtitles, and screen descriptions, chapters, and metadata.

  2. Add a <track> element inside your <video> element with the kind attribute set to "captions", src attribute pointing to your .vtt file, and label attribute for user-readable title.

Adding Transcripts:

Transcripts are a text version of the speech and non-speech audio information needed to understand the content. They may include the same language as the original audio or a translation to another language.

To add transcripts to a video, you can place the text of the transcript below the video, inside a <div> or <p> tag. You could also make the transcript interactive by synchronizing it with the video.

3. Code Examples

Adding Captions:

<video controls>
   <source src="myVideo.mp4" type="video/mp4">
   <track kind="captions" src="captions_en.vtt" srclang="en" label="English">
</video>

Explanation:

  • The <video> tag is used to embed video content.
  • The <source> tag is used to specify multiple media resources for media elements, such as <video>, <audio>, <picture>, and <iframe>.
  • The <track> tag is used to specify external text track resources, such as captions, subtitles, etc.

Adding Transcripts:

<video id="myVideo" controls>
   <source src="myVideo.mp4" type="video/mp4">
</video>

<div id="transcript">
   <p>Transcript: Hello, welcome to our tutorial...</p>
</div>

Explanation:

  • The <div> tag defines a division or a section in an HTML document.
  • The <p> tag defines a paragraph.

4. Summary

We have learned how to use HTML to add captions and transcripts to videos, making them accessible to a wider audience. You can now try adding captions and transcripts to a video of your choice.

5. Practice Exercises

  1. Add English and Spanish captions to a video.
<!-- Your code here -->
  1. Add a transcript to a video and style it with CSS.
<!-- Your code here -->

Solutions:

  1. Adding English and Spanish captions:
<video controls>
   <source src="myVideo.mp4" type="video/mp4">
   <track kind="captions" src="captions_en.vtt" srclang="en" label="English">
   <track kind="captions" src="captions_es.vtt" srclang="es" label="Spanish">
</video>
  1. Adding a transcript and styling it with CSS:
<video id="myVideo" controls>
   <source src="myVideo.mp4" type="video/mp4">
</video>

<div id="transcript" style="font-size:16px; color:blue;">
   <p>Transcript: Hello, welcome to our tutorial...</p>
</div>

To further practice, try adding more languages to the captions and changing the style of the transcript. You can also try to make the transcript interactive by synchronizing it with the video.

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

HTML

Learn the fundamental building blocks of the web using HTML.

Explore

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

Random Name Generator

Generate realistic names with customizable options.

Use tool

Image Compressor

Reduce image file sizes while maintaining quality.

Use tool

Word Counter

Count words, characters, sentences, and paragraphs in real-time.

Use tool

Base64 Encoder/Decoder

Encode and decode Base64 strings.

Use tool

JWT Decoder

Decode and validate JSON Web Tokens (JWT).

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help