aboutsummaryrefslogtreecommitdiff
path: root/files/uk/web/html/element/video/index.html
blob: ecfce1d8675aabb4a417cfd086efdff4b3ebca1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
---
title: '<video>: Вбудований елемент Відео'
slug: Web/HTML/Element/video
translation_of: Web/HTML/Element/video
original_slug: Web/HTML/Елемент/video
---
<div>{{HTMLRef}}</div>

<p><span class="seoSummary"><strong>HTML Елемент Video</strong> (<strong><code>&lt;video&gt;</code></strong>) вбудовує медіа плеєр, який підтримує відтворення відео в документі.</span> Ви можете використовувати тег <code>&lt;video&gt;</code> також для аудіо, однак елемент {{HTMLElement("audio")}} може надати кращий користувацький досвід.</p>

<div>{{EmbedInteractiveExample("pages/tabbed/video.html", "tabbed-standard")}}</div>

<p class="hidden">Код цих інтерактивних прикладів доступний на репозиторії GitHub. Якщо ви хочете долучитися до розробки інтерактивних прикладів, клонуйте <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples </a>та надішліть нам запит на додавання.</p>

<p>Наступні приклади показують просте використання елементу <code>&lt;video&gt;</code>. In a similar manner to the {{htmlelement("img")}} element, we include a path to the media we want to display inside the <code>src</code> attribute; we can include other attributes to specify information such as video width and height, whether we want it to autoplay and loop, whether we want to show the browser's default video controls, etc.</p>

<p>The content inside the opening and closing <code>&lt;video&gt;&lt;/video&gt;</code> tags is shown as a fallback in browsers that don't support the element.</p>

<p>Browsers don't all support the same <a href="/en-US/docs/Web/HTML/Supported_media_formats">video formats</a>; you can provide multiple sources inside nested {{htmlelement("source")}} elements, and the browser will then use the first one it understands:</p>

<pre class="brush: html">&lt;video controls&gt;
  &lt;source src="myVideo.mp4" type="video/mp4"&gt;
  &lt;source src="myVideo.webm" type="video/webm"&gt;
  &lt;p&gt;Your browser doesn't support HTML5 video. Here is
     a &lt;a href="myVideo.mp4"&gt;link to the video&lt;/a&gt; instead.&lt;/p&gt;
&lt;/video&gt;</pre>

<p>Other usage notes:</p>

<ul>
 <li>If you don't specify the <code>controls</code> attribute, the video won't include the browser's default controls; you can create your own custom controls using JavaScript and the {{domxref("HTMLMediaElement")}} API. See <a href="/en-US/docs/Web/Apps/Fundamentals/Audio_and_video_delivery/cross_browser_video_player">Creating a cross-browser video player</a> for more details.</li>
 <li>To allow precise control over your video (and audio) content, <code>HTMLMediaElement</code>s fire many different <a href="/en-US/docs/Web/Guide/Events/Media_events">events</a>.</li>
 <li>You can use the {{cssxref("object-position")}} property to adjust the positioning of the video within the element's frame, and the {{cssxref("object-fit")}} property to control how the video's size is adjusted to fit within the frame.</li>
 <li>To show subtitles/captions along with your video, you can use some JavaScript along with the {{htmlelement("track")}} element and the <a href="/en-US/docs/Web/API/WebVTT_API">WebVTT</a> format. See <a href="/en-US/docs/Web/Apps/Fundamentals/Audio_and_video_delivery/Adding_captions_and_subtitles_to_HTML5_video">Adding captions and subtitles to HTML5 video</a> for more information.</li>
</ul>

<p>A good general source of information on using HTML <code>&lt;video&gt;</code> is the <a href="/en-US/docs/Learn/HTML/Multimedia_and_embedding/Video_and_audio_content">Video and audio content</a> beginner's tutorial.</p>

<h2 id="Attributes">Attributes</h2>

<p>Like all other HTML elements, this element supports the <a href="/en-US/docs/Web/HTML/Global_attributes">global attributes</a>.</p>

<dl>
 <dt>{{htmlattrdef("autoplay")}}</dt>
 <dd>A Boolean attribute; if specified, the video automatically begins to play back as soon as it can do so without stopping to finish loading the data.</dd>
 <dd>
 <p class="note"><strong>Note</strong>: Sites that automatically play audio (or video with an audio track) can be an unpleasant experience for users, so it should be avoided when possible. If you must offer autoplay functionality, you should make it opt-in (requiring a user to specifically enable it). However, this can be useful when creating media elements whose source will be set at a later time, under user control.</p>

 <p class="note">To disable video autoplay, <code>autoplay="false"</code> will not work; the video will autoplay if the attribute is there in the <code>&lt;video&gt;</code> tag at all. To remove autoplay the attribute needs to be removed altogether.</p>

 <p class="note">In some browsers (e.g. Chrome 70.0) autoplay is not working if no <code>muted</code> attribute is present.</p>
 </dd>
</dl>

<dl>
 <dt><code><a href="https://wicg.github.io/picture-in-picture/#auto-pip">autoPictureInPicture</a></code> {{experimental_inline}}</dt>
 <dd>Allows for automatic Picture-in-Picture behavior when the user switches back and forth between the web app and other applications/tab.</dd>
 <dt>{{htmlattrdef("buffered")}}</dt>
 <dd>An attribute you can read to determine the time ranges of the buffered media. This attribute contains a {{domxref("TimeRanges")}} object.</dd>
 <dt>{{htmlattrdef("controls")}}</dt>
 <dd>If this attribute is present, the browser will offer controls to allow the user to control video playback, including volume, seeking, and pause/resume playback.</dd>
 <dt>{{htmlattrdef("controlslist")}} {{experimental_inline}}</dt>
 <dd>The <code><a href="https://wicg.github.io/controls-list/html-output/multipage/embedded-content.html#attr-media-controlslist">controlslist</a></code> attribute, when specified, helps the browser select what controls to show on the media element whenever the browser shows its own set of controls (e.g. when the <code>controls</code> attribute is specified).</dd>
 <dd>The allowed values are <code>nodownload</code>, <code>nofullscreen</code> and <code>noremoteplayback</code>.</dd>
 <dd class="note">Use the <code>disablePictureInPicture</code> attribute if you want to disable the Picture-In-Picture mode (and the control).</dd>
 <dt>{{htmlattrdef("crossorigin")}}</dt>
 <dd>This enumerated attribute indicates whether to use CORS to fetch the related image. <a href="/en-US/docs/CORS_Enabled_Image">CORS-enabled resources</a> can be reused in the {{HTMLElement("canvas")}} element without being <em>tainted</em>. The allowed values are:
 <dl>
  <dt><code>anonymous</code></dt>
  <dd>Sends a cross-origin request without a credential. In other words, it sends the <code>Origin:</code> HTTP header without a cookie, X.509 certificate, or performing HTTP Basic authentication. If the server does not give credentials to the origin site (by not setting the <code>Access-Control-Allow-Origin:</code> HTTP header), the image will be <em>tainted</em>, and its usage restricted.</dd>
  <dt><code>use-credentials</code></dt>
  <dd>Sends a cross-origin request with a credential. In other words, it sends the <code>Origin:</code> HTTP header with a cookie, a certificate, or performing HTTP Basic authentication. If the server does not give credentials to the origin site (through <code>Access-Control-Allow-Credentials:</code> HTTP header), the image will be <em>tainted</em> and its usage restricted.</dd>
 </dl>
 When not present, the resource is fetched without a CORS request (i.e. without sending the <code>Origin:</code> HTTP header), preventing its non-tainted used in {{HTMLElement('canvas')}} elements. If invalid, it is handled as if the enumerated keyword <code>anonymous</code> was used. See <a href="/en-US/docs/HTML/CORS_settings_attributes">CORS settings attributes</a> for additional information.</dd>
 <dt>{{htmlattrdef("height")}}</dt>
 <dd>The height of the video's display area, in <a href="https://drafts.csswg.org/css-values/#px">CSS pixels</a> (absolute values only; <a href="https://html.spec.whatwg.org/multipage/embedded-content.html#dimension-attributes">no percentages</a>.)</dd>
 <dt>{{htmlattrdef("intrinsicsize")}} {{experimental_inline}}</dt>
 <dd>This attribute tells the browser to ignore the actual intrinsic size of the image and pretend it’s the size specified in the attribute. Specifically, the image would raster at these dimensions and <code>naturalWidth</code>/<code>naturalHeight</code> on images would return the values specified in this attribute. <a href="https://github.com/ojanvafai/intrinsicsize-attribute">Explainer</a>, <a href="https://googlechrome.github.io/samples/intrinsic-size/index.html">examples</a></dd>
 <dt>{{htmlattrdef("loop")}}</dt>
 <dd>A Boolean attribute; if specified, the browser will automatically seek back to the start upon reaching the end of the video.</dd>
 <dt>{{htmlattrdef("muted")}}</dt>
 <dd>A Boolean attribute that indicates the default setting of the audio contained in the video. If set, the audio will be initially silenced. Its default value is <code>false</code>, meaning that the audio will be played when the video is played.</dd>
 <dt><code><a href="https://wicg.github.io/picture-in-picture/#disable-pip">disablePictureInPicture</a></code> {{experimental_inline}}</dt>
 <dd>Prevents the browser from suggesting a Picture-in-Picture context menu or to request Picture-in-Picture automatically in some cases.</dd>
 <dt>{{htmlattrdef("playsinline")}}</dt>
 <dd>A Boolean attribute indicating that the video is to be played "inline", that is within the element's playback area. Note that the absence of this attribute <em>does not</em> imply that the video will always be played in fullscreen.</dd>
 <dt>{{htmlattrdef("poster")}}</dt>
 <dd>A URL for an image to be shown while the video is downloading. If this attribute isn't specified, nothing is displayed until the first frame is available, then the first frame is shown as the poster frame.</dd>
 <dt>{{htmlattrdef("preload")}}</dt>
 <dd>This enumerated attribute is intended to provide a hint to the browser about what the author thinks will lead to the best user experience with regards to what content is loaded before the video is played. It may have one of the following values:
 <ul>
  <li><code>none</code>: Indicates that the video should not be preloaded.</li>
  <li><code>metadata</code>: Indicates that only video metadata (e.g. length) is fetched.</li>
  <li><code>auto</code>: Indicates that the whole video file can be downloaded, even if the user is not expected to use it.</li>
  <li><em>empty string</em>: Synonym of the <code>auto</code> value.</li>
 </ul>

 <p>The default value is different for each browser. The spec advises it to be set to <code>metadata</code>.</p>

 <div class="note"><strong>Notes:</strong>

 <ul>
  <li>The <code>autoplay</code> attribute has precedence over <code>preload</code>. If <code>autoplay</code> is specified, the browser would obviously need to start downloading the video for playback.</li>
  <li>The specification does not force the browser to follow the value of this attribute; it is a mere hint.</li>
 </ul>
 </div>
 </dd>
 <dt></dt>
 <dt>{{htmlattrdef("src")}}</dt>
 <dd>The URL of the video to embed. This is optional; you may instead use the {{HTMLElement("source")}} element within the video block to specify the video to embed.</dd>
 <dt>{{htmlattrdef("width")}}</dt>
 <dd>The width of the video's display area, in <a href="https://drafts.csswg.org/css-values/#px">CSS pixels</a> (absolute values only; <a href="https://html.spec.whatwg.org/multipage/embedded-content.html#dimension-attributes">no percentages</a>).</dd>
 <dt></dt>
</dl>

<h2 id="Events">Events</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Event Name</th>
   <th scope="col">Fired When</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{domxref("ScriptProcessorNode.audioprocess_event","audioprocess")}}{{Deprecated_Inline}}</td>
   <td>The input buffer of a {{DOMxRef("ScriptProcessorNode")}} is ready to be processed.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.canplay_event", 'canplay')}}</td>
   <td>The browser can play the media, but estimates that not enough data has been loaded to play the media up to its end without having to stop for further buffering of content.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.canplaythrough_event", 'canplaythrough')}}</td>
   <td>The browser estimates it can play the media up to its end without stopping for content buffering.</td>
  </tr>
  <tr>
   <td>{{domxref("OfflineAudioContext.complete_event", "complete")}}</td>
   <td>The rendering of an {{DOMxRef("OfflineAudioContext")}} is terminated.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.durationchange_event", 'durationchange')}}</td>
   <td>The <code>duration</code> attribute has been updated.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.emptied_event", 'emptied')}}</td>
   <td>The media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the <a href="/en-US/docs/XPCOM_Interface_Reference/NsIDOMHTMLMediaElement" rel="internal"><code>load()</code></a> method is called to reload it.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.ended_event", 'ended')}}</td>
   <td>Playback has stopped because the end of the media was reached.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.loadeddata_event", 'loadeddata')}}</td>
   <td>The first frame of the media has finished loading.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.loadedmetadata_event", 'loadedmetadata')}}</td>
   <td>The metadata has been loaded.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.pause_event", 'pause')}}</td>
   <td>Playback has been paused.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.play_event", 'play')}}</td>
   <td>Playback has begun.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.playing_event", 'playing ')}}</td>
   <td>Playback is ready to start after having been paused or delayed due to lack of data.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.progress_event", 'progress')}}</td>
   <td>Fired periodically as the browser loads a resource.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.ratechange_event", 'ratechange')}}</td>
   <td>The playback rate has changed.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.seeked_event", 'seeked')}}</td>
   <td>A <em>seek</em> operation completed.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.seeking_event", 'seeking')}}</td>
   <td>A <em>seek</em> operation began.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.stalled_event", 'stalled')}}</td>
   <td>The user agent is trying to fetch media data, but data is unexpectedly not forthcoming.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.suspend_event", 'suspend')}}</td>
   <td>Media data loading has been suspended.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.timeupdate_event", 'timeupdate')}}</td>
   <td>The time indicated by the <code>currentTime</code> attribute has been updated.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.volumechange_event", 'volumechange')}}</td>
   <td>The volume has changed.</td>
  </tr>
  <tr>
   <td>{{domxref("HTMLMediaElement.waiting_event", 'waiting')}}</td>
   <td>Playback has stopped because of a temporary lack of data</td>
  </tr>
 </tbody>
</table>

<h2 id="Usage_notes">Usage notes</h2>

<h3 id="Styling_with_CSS">Styling with CSS</h3>

<p>The <code>&lt;video&gt;</code> element is a replaced element — its {{cssxref("display")}} value is <code>inline</code> by default, but its default width and height in the viewport is defined by the video being embedded.</p>

<p>There are no special considerations for styling <code>&lt;video&gt;</code>; a common strategy is to give it a <code>display</code> value of <code>block</code> to make it easier to position, size, etc., and then provide styling and layout information as required. <a href="/en-US/docs/Web/Apps/Fundamentals/Audio_and_video_delivery/Video_player_styling_basics">Video player styling basics</a> provides some useful styling techniques.</p>

<h3 id="Detecting_track_addition_and_removal">Detecting track addition and removal</h3>

<p>You can detect when tracks are added to and removed from a <code>&lt;video&gt;</code> element using the {{event("addtrack")}} and {{event("removetrack")}} events. However, these events aren't sent directly to the <code>&lt;video&gt;</code> element itself. Instead, they're sent to the track list object within the <code>&lt;video&gt;</code> element's {{domxref("HTMLMediaElement")}} that corresponds to the type of track that was added to the element:</p>

<dl>
 <dt>{{domxref("HTMLMediaElement.audioTracks")}}</dt>
 <dd>An {{domxref("AudioTrackList")}} containing all of the media element's audio tracks. You can add a listener for <code>addtrack</code> to this object to be alerted when new audio tracks are added to the element.</dd>
 <dt>{{domxref("HTMLMediaElement.videoTracks")}}</dt>
 <dd>Add an <code>addtrack</code> listener to this {{domxref("VideoTrackList")}} object to be informed when video tracks are added to the element.</dd>
 <dt>{{domxref("HTMLMediaElement.textTracks")}}</dt>
 <dd>Add an <code>addtrack</code> event listener to this {{domxref("TextTrackList")}} to be notified when new text tracks are added to the element.</dd>
</dl>

<p>For example, to detect when audio tracks are added to or removed from a <code>&lt;video&gt;</code> element, you can use code like this:</p>

<pre class="brush: js">var elem = document.querySelector("video");

elem.audioTrackList.onaddtrack = function(event) {
  trackEditor.addTrack(event.track);
};

elem.audioTrackList.onremovetrack = function(event) {
  trackEditor.removeTrack(event.track);
};
</pre>

<p>This code watches for audio tracks to be added to and removed from the element, and calls a hypothetical function on a track editor to register and remove the track from the editor's list of available tracks.</p>

<p>You can also use {{domxref("EventTarget.addEventListener", "addEventListener()")}} to listen for the {{event("addtrack")}} and {{event("removetrack")}} events.</p>

<h2 id="Examples">Examples</h2>

<h3 id="Simple_video_example">Simple video example</h3>

<p>This example plays a video when activated, providing the user with the browser's default video controls to control playback.</p>

<pre class="brush: html">&lt;!-- Simple video example --&gt;
&lt;!-- 'Big Buck Bunny' licensed under CC 3.0 by the Blender foundation. Hosted by archive.org --&gt;
&lt;!-- Poster from peach.blender.org --&gt;
&lt;video controls
    src="https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4"
    poster="https://peach.blender.org/wp-content/uploads/title_anouncement.jpg?x11217"
    width="620"&gt;

Sorry, your browser doesn't support embedded videos,
but don't worry, you can &lt;a href="https://archive.org/details/BigBuckBunny_124"&gt;download it&lt;/a&gt;
and watch it with your favorite video player!

&lt;/video&gt;</pre>

<p>{{EmbedLiveSample('Simple_video_example', '640', '370', '', 'Web/HTML/Element/video')}}</p>

<p>Until the video starts playing, the image provided in the <code>poster</code> attribute is displayed in its place. If the browser doesn't support video playback, the fallback text is displayed.</p>

<h3 id="Multiple_sources_example">Multiple sources example</h3>

<p>This example builds on the last one, offering three different sources for the media; this allows the video to be watched regardless of which video codecs are supported by the browser.</p>

<pre class="brush: html">&lt;!-- Using multiple sources as fallbacks for a video tag --&gt;
&lt;!-- 'Elephants Dream' by Orange Open Movie Project Studio, licensed under CC-3.0, hosted by archive.org --&gt;
&lt;!-- Poster hosted by Wikimedia --&gt;
&lt;video width="620" controls
  poster="https://upload.wikimedia.org/wikipedia/commons/e/e8/Elephants_Dream_s5_both.jpg" &gt;
  &lt;source
    src="https://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"
    type="video/mp4"&gt;
  &lt;source
    src="https://archive.org/download/ElephantsDream/ed_hd.ogv"
    type="video/ogg"&gt;
  &lt;source
    src="https://archive.org/download/ElephantsDream/ed_hd.avi"
    type="video/avi"&gt;
  Your browser doesn't support HTML5 video tag.
&lt;/video&gt;</pre>

<p>{{EmbedLiveSample('Multiple_sources_example', '640', '370', '', 'Web/HTML/Element/video')}}</p>

<p>First WebM is tried. If that can't be played, then MP4 is tried. Finally, OGG is tried. A fallback message is displayed if the video tag isn't supported, but not if all sources fail.</p>

<h3 id="Server_support_for_video">Server support for video</h3>

<p>If the MIME type for the video is not set correctly on the server, the video may not show or show a gray box containing an X (if JavaScript is enabled).</p>

<p>If you use Apache Web Server to serve Ogg Theora videos, you can fix this problem by adding the video file type extensions to "video/ogg" MIME type. The most common video file type extensions are ".ogm", ".ogv", or ".ogg". To do this, edit the "mime.types" file in "/etc/apache" or use the <code>"AddType"</code> configuration directive in <code>httpd.conf</code>.</p>

<pre class="eval">AddType video/ogg .ogm
AddType video/ogg .ogv
AddType video/ogg .ogg
</pre>

<p>If you serve your videos as WebM, you can fix this problem for the Apache Web Server by adding the extension used by your video files (".webm" is the most common one) to the MIME type "video/webm" via the "mime.types" file in "/etc/apache" or via the "AddType" configuration directive in <code>httpd.conf</code>.</p>

<pre class="eval">AddType video/webm .webm
</pre>

<p>Your web host may provide an easy interface to MIME type configuration changes for new technologies until a global update naturally occurs.</p>

<h2 id="Accessibility_concerns">Accessibility concerns</h2>

<p>Videos should provide both captions and transcripts that accurately describe its content (see <a href="/en-US/docs/Web/Apps/Fundamentals/Audio_and_video_delivery/Adding_captions_and_subtitles_to_HTML5_video">Adding captions and subtitles to HTML5 video</a> for more information on how to implement these). Captions allow people who are experiencing hearing loss to understand a video's audio content as the video is being played, while transcripts allow people who need additional time to be able to review audio content at a pace and format that is comfortable for them.</p>

<p>If automatic captioning services are used, it is important to review the generated content to ensure it accurately represents the source video.</p>

<p>In addition to spoken dialog, subtitles and transcripts should also identify music and sound effects that communicate important information. This includes emotion and tone:</p>

<pre class="eval">14
00:03:14 --&gt; 00:03:18
[Dramatic rock music]

15
00:03:19 --&gt; 00:03:21
[whispering] What's that off in the distance?

16
00:03:22 --&gt; 00:03:24
It's… it's a…

16 00:03:25 --&gt; 00:03:32
[Loud thumping]
[Dishes clattering]
</pre>

<p>Captions should not obstruct the main subject of the video. They can be positioned using <a href="/en-US/docs/Web/API/WebVTT_API#Cue_settings">the <code>align</code> VTT cue setting</a>.</p>

<ul>
 <li><a href="/en-US/docs/Plugins/Flash_to_HTML5/Video/Subtitles_captions">MDN Subtitles and closed caption — Plugins</a></li>
 <li><a href="/en-US/docs/Web/API/WebVTT_API">Web Video Text Tracks Format (WebVTT)</a></li>
 <li><a href="https://webaim.org/techniques/captions/">WebAIM: Captions, Transcripts, and Audio Descriptions</a></li>
 <li><a href="/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable#Guideline_1.2_—_Providing_text_alternatives_for_time-based_media">MDN Understanding WCAG, Guideline 1.2 explanations</a></li>
 <li><a href="https://www.w3.org/TR/UNDERSTANDING-WCAG20/media-equiv-av-only-alt.html">Understanding Success Criterion 1.2.1 | W3C Understanding WCAG 2.0</a></li>
 <li><a href="https://www.w3.org/TR/UNDERSTANDING-WCAG20/media-equiv-captions.html">Understanding Success Criterion 1.2.2 | W3C Understanding WCAG 2.0</a></li>
</ul>

<h2 id="Technical_summary">Technical summary</h2>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row"><a href="/en-US/docs/Web/HTML/Content_categories">Content categories</a></th>
   <td><a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">Flow content</a>, phrasing content, embedded content. If it has a {{htmlattrxref("controls", "video")}} attribute: interactive content and palpable content.</td>
  </tr>
  <tr>
   <th scope="row">Permitted content</th>
   <td>
    <p>If the element has a {{htmlattrxref("src", "video")}} attribute: zero or more {{HTMLElement("track")}} elements, followed by transparent content that contains no media elements–that is no {{HTMLElement("audio")}} or {{HTMLElement("video")}}</p>

    <p>Else: zero or more {{HTMLElement("source")}} elements, followed by zero or more {{HTMLElement("track")}} elements, followed by transparent content that contains no media elements–that is no {{HTMLElement("audio")}} or {{HTMLElement("video")}}.</p>
   </td>
  </tr>
  <tr>
   <th scope="row">Tag omission</th>
   <td>{{no_tag_omission}}</td>
  </tr>
  <tr>
   <th scope="row">Permitted parents</th>
   <td>Any element that accepts embedded content.</td>
  </tr>
  <tr>
   <th scope="row">Permitted ARIA roles</th>
   <td>{{ARIARole("application")}}</td>
  </tr>
  <tr>
   <th scope="row">DOM interface</th>
   <td>{{domxref("HTMLVideoElement")}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Feedback</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'embedded-content.html#the-video-element', '&lt;video&gt;')}}</td>
   <td><a href="https://github.com/whatwg/html/issues">WHATWG HTML GitHub issues</a></td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>



<p>{{Compat("html.elements.video")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en-US/docs/Media_formats_supported_by_the_audio_and_video_elements">Media formats supported by the audio and video elements</a></li>
 <li>Positioning and sizing the picture within its frame: {{cssxref("object-position")}} and {{cssxref("object-fit")}}</li>
 <li>{{htmlelement("audio")}}</li>
 <li><a href="/en-US/docs/Using_HTML5_audio_and_video">Using HTML5 audio and video</a></li>
 <li><a href="/en-US/docs/Manipulating_video_using_canvas">Manipulating video using canvas</a></li>
 <li><a href="/en-US/docs/Configuring_servers_for_Ogg_media">Configuring servers for Ogg media</a></li>
</ul>