HTML and CSS Reference
In-Depth Information
CHAPTER 4
Native Audio
Emily Lewis
4.0 Introduction
You already deal with
embedded content
—content that is imported or inserted
into a web page—almost every day (see
http://www.w3.org/TR/html5/content-models
image—into your web page via the
src
attribute.
With HTML5, we now have many more options for embedded content, including
Native? Yes. That means no more ungainly
object
and
embed
. No more need to deliver
audio with a third-party plug-in and, as such, no more design headaches with dynamic
layouts or drop-down menus.
With
audio
in our arsenal, not only can we deliver audio files directly through the
browser, but we can style and manipulate the element and its attributes via CSS and
JavaScript.
4.1 Adding HTML5 Audio
Problem
You want to play native audio on your web page.
Solution
Add the
audio
element, with the
src
attribute referencing the location of your audio
file and fallback content for older browsers:
