Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Video and Audio (Retired) Captioning Video The Track Element

Emma Schwartz
Emma Schwartz
4,019 Points

How do you get captions on my website?~~~HTML <track label="English" kind="subtitles" srclang="en" src="bridge-captions

I tried this code: < track label="English" kind="subtitles" srclang="en" src="bridge-captions.vtt" default > and it did not work.

8 Answers

Emma Schwartz
Emma Schwartz
4,019 Points

The VTT did not work ~~~VTT WEBVTT FILE

0 00:00:00.500 --> 00:00:05.000 [truck engine]

1 00:00:06.000 --> 00:00:10.000 [birds chirping]

2 00:00:13.000 --> 00:00:16.000 [shool bus engine]

3 00:00:17.000 --> 00:00:24.350 [water flowing]

4 00:00:24.350 --> 00:00:30.000 [water flow continues]

Your code contains an error.

src="bridge-captions.vtt" <!-- this is where your error occurs -->

Do not use "bridge-captions.vtt", use "bridge.vtt" instead. Simply remove "-captions" as it is not needed in the src.

Here is the full block of code:

<video controls>
   <track label="English" kind="subtitles" srclang="en" src="bridge.vtt">
   <source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.mp4" type="video/mp4">
   <source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.ogg" type="video/ogg">
</video>
Tom Nguyen
Tom Nguyen
33,501 Points

solution:

index.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML Video and Audio</title>

    <link rel="stylesheet" href="normalize.css">
    <link href='http://fonts.googleapis.com/css?family=Nunito:400,300' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="main.css">
  </head>
  <body>

    <h1>HTML Video and Audio</h1>

    <div class="wrapper">

      <video controls>
        <source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.mp4" type="video/mp4">
        <source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.ogg" type="video/ogg">
        <track label="English" kind="subtitles" srclang="en" src="bridge.vtt">
      </video>

    </div>

  </body>
</html>

Hi Emma,

Look great, you don't need to put spaces inside track

< track label="English" kind="subtitles" srclang="en" src="bridge-captions.vtt" default >

should be like this without space between.

<track label="English" kind="subtitles" srclang="en" src="bridge-captions.vtt" default>

Example - @2:35

More details in MDN Documentation

Emma Schwartz
Emma Schwartz
4,019 Points

I had to put spaces. I did do that but it did not work

Okay, can you try to refresh it again? I have tested as it is passed on my side.

<video controls>
    <source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.mp4" type="video/mp4">
    <source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.ogg" type="video/ogg">
    <track label="English" kind="subtitles" srclang="en" src="bridge-captions.vtt" default>
</video>

Challenge Task 5 of 5

On the <track> element, add a src attribute with the value "bridge.vtt"

Not sure what went wrong, can you try to add "bridge.vtt" under src

   <track label="English" kind="subtitles" srclang="en" src="bridge.vtt">
Emma Schwartz
Emma Schwartz
4,019 Points

It still does not work.

Emma Schwartz
Emma Schwartz
4,019 Points

Thanks for the help!