48 | Lesson 2The three primary types of audio files supported <strong>by</strong> popular browsers are OGG, MP3, andWAV. However, not every browser supports every audio file format, at least not today. For <strong>the</strong>most part, MP3 is <strong>the</strong> best choice for multiple browser compatibility.To help ensure your audio plays on <strong>the</strong> majority of browsers and devices, use <strong>the</strong> sourceattribute to include multiple formats in your markup. This example shows <strong>the</strong> same audiofile available in two formats:LICENSED PRODUCT NOT FOR RESALEYou can find a lot of free audio files, which are also royalty and copyright free, athttp://flashkit.com. This is a good resource for learners, and for developers who may needa sound effect for a project. Ano<strong>the</strong>r source is <strong>the</strong> Public Domain Sherpa Web site athttp://www.publicdomainsherpa.com/public-domain-recordings.html. You can also makeyour own recordings using your computer and recording software. Windows 7 includes <strong>the</strong>Sound Recorder, which lets you save audio files in WAV format.Figure 2-19<strong>HTML5</strong> default audio controlsin a Web browserWORK WITH THE AUDIO ELEMENTGET READY. To work with <strong>the</strong> <strong>HTML5</strong> audio element, perform <strong>the</strong> following steps:1. Locate an audio clip.2. In your editing tool, create an HTML file with <strong>the</strong> following markup. Substitute <strong>the</strong>appropriate file name for your audio clip.Audio Test3. Save your file as L2-audio.html and view it in a browser. You should see somethingsimilar to Figure 2-19. Because we didn’t include <strong>the</strong> autoplay attribute in thisexample, you need to click <strong>the</strong> Play button to start <strong>the</strong> audio clip.
<strong>Building</strong> <strong>the</strong> <strong>User</strong> <strong>Interface</strong> <strong>by</strong> <strong>Using</strong> <strong>HTML5</strong>: <strong>Text</strong>, <strong>Graphics</strong>, and Media | 494. If <strong>the</strong> audio controls don’t appear, go to <strong>the</strong> W3C Markup Validation Service Webpage at http://validator.w3.org. Upload L2-audio.html and click Check to have <strong>the</strong>service check it. Fix any errors reported <strong>by</strong> <strong>the</strong> checker that relate to missing tagsor typos, if any.5. Save <strong>the</strong> file again and open it in a Web browser. Play <strong>the</strong> audio clip.6. Close any open files, including <strong>the</strong> editing tool and Web browser.LICENSED PRODUCT NOT FOR RESALE✚ MORE INFORMATIONFor more information on incorporating multimedia into <strong>HTML5</strong> Web pages, and <strong>the</strong> audio and video elements inparticular, go to http://msdn.microsoft.com/en-us/library/ie/hh771805(v=vs.85).aspx.SKILL SUMMARYIN THIS LESSON YOU LEARNED:• Hypertext Markup Language (HTML) uses markup to describe content for display on aWeb page.• An element is <strong>the</strong> combination of tags and <strong>the</strong> content <strong>the</strong>y enclose. You may need to usespecial characters on a Web page, which requires character encoding.• Every Web page requires <strong>the</strong> doctype declaration at <strong>the</strong> top of <strong>the</strong> page.• <strong>HTML5</strong> uses most of <strong>the</strong> same elements and attributes specified in HTML 4, and has introducedsome new tags, modified <strong>the</strong> preferred usage of o<strong>the</strong>rs, and no longer supports certainelements. New text-related elements include command, mark, time, meter, and progress. Afew of <strong>the</strong> deprecated elements are basefont, center, font, and strike.• Use <strong>the</strong> img element to display linked images in a Web page. The images can be locatedwith <strong>the</strong> Web pages HTML files, usually in an images subfolder, or on a different <strong>server</strong> orWeb site.• The figure and figure caption elements are new to <strong>HTML5</strong> and give you more controlor <strong>the</strong> type of image you are displaying and <strong>the</strong> ability to include captions.• The canvas element is used for drawing, rendering, and manipulating images and graphicsdynamically in <strong>HTML5</strong>.• Scalable Vector <strong>Graphics</strong> (SVG) enables you to create scalable objects that resize to bestfit <strong>the</strong> screen on which <strong>the</strong>y’re viewed, whe<strong>the</strong>r a PC screen or a smartphone.• <strong>HTML5</strong> introduces <strong>the</strong> audio and video elements, which do away with <strong>the</strong> need forplug-ins or media players to listen to music or watch videos via a Web browser.■ Knowledge AssessmentFill in <strong>the</strong> BlankComplete <strong>the</strong> following sentences <strong>by</strong> writing <strong>the</strong> correct word or words in <strong>the</strong> blanks provided.1. An HTML tag that doesn’t require an end tag is called a(n) tag.2. A(n) works with an element to describe data in enough detailfor rendering.3. The is a declaration that is found at <strong>the</strong> very top of almost every Web page.4. A element or attribute has been removed from <strong>the</strong> list of availableHTML elements according to <strong>the</strong> W3C.