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…
Section overview
5 resourcesExplores 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:
-
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.
-
Add a
<track>element inside your<video>element with thekindattribute set to "captions",srcattribute pointing to your .vtt file, andlabelattribute 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
- Add English and Spanish captions to a video.
<!-- Your code here -->
- Add a transcript to a video and style it with CSS.
<!-- Your code here -->
Solutions:
- 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>
- 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.
Related topics
Keep learning with adjacent tracks.
Popular tools
Helpful utilities for quick tasks.
Latest articles
Fresh insights from the CodiWiki team.
AI in Drug Discovery: Accelerating Medical Breakthroughs
In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…
Read articleAI in Retail: Personalized Shopping and Inventory Management
In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …
Read articleAI 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 articleAI 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 articleAI in Legal Compliance: Ensuring Regulatory Adherence
In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…
Read article