O'Reilly logo

Responsive Web Design with HTML5 and CSS3 by Ben Frain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding video and audio the HTML5 way

I'll be honest. I've always found adding media such as video and audio into a web page is an utter pain in HTML 4.01. It's not difficult, just messy. HTML5 makes things far easier. The syntax is much like adding an image:

<video src="myVideo.ogg"></video>

A breath of fresh air for most web designers! Rather than the abundance of code currently needed to include video in a page, HTML5 allows a single <video></video>tag (or <audio></audio> for audio) to do all the heavy lifting. It's also possible to insert text between the opening and closing tag to inform users when they aren't using an HTML5 compatible browser and there are additional attributes you'd ordinarily want to add, such as the height and width. Let's ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required