HTML and CSS Reference
In-Depth Information
Figure 9.10 An anchor text audio fallback for when a browser doesn't support the
<audio> element
To review the previous code, the <audio> element includes the controls Boolean at-
tribute to ensure the audio player is displayed within browsers that support the element.
The <audio> element does not include a src attribute and instead wraps three different
<source> elements. Each <source> element includes a src attribute that references a
different audio file format and a type attribute to identify the format of the audio file. As
a last fallback, if a browser doesn't recognize any of the audio file formats, the anchor link
to download the element will be displayed.
In addition to the <audio> element, HTML5 also introduced the <video> element,
which shares quite a few similarities with the <audio> element.
Adding Video
Adding video in HTML5 is very similar to adding audio. We use the <video> element in
place of the <audio> element. All of the same attributes ( src , autoplay , controls ,
loop , and preload ) and fallbacks apply here, too.
With the <audio> element, if the controls Boolean attribute isn't specified the audio
clip isn't displayed. With videos, if the controls Boolean attribute is not specified the
video will display. However, it is fairly difficult to view unless the autoplay Boolean
attribute is also applied. In general, the best practice here is to include the controls
Boolean attribute unless there is a good reason not to allow users to start, stop, or replay
the video.
Search WWH ::




Custom Search