These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:26 pm Advanced search

Use of Audio element confusing?

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

Use of Audio element confusing?

Postby OmegaJunior » Mon Oct 08, 2007 10:52 am

Greetings!

(I thought I posted this already. I didn't see it in my own posts anymore, so in case it exists twice now, please help me remove the duplicate.)

The html5 specification seems to make using an Audio element straightforward:

Code: Select all
<audio src="music.ogg" controls="controls"></audio>


(Not sure if it needs a closing tag, btw.)

Then maybe we want to add some fallback content:

Code: Select all
<audio src="music.ogg" controls="controls">
<p>Listen to this!</p>
<p><a href="music.ogg" type="application/ogg">Music</a></p>
</audio>


And we may want to specify several media sources:

Code: Select all
<audio controls="controls">
<source src="music.ogg" type="application/ogg"></source>
<source src="music.mp3" type="audio/mp3"></source>
<p>Listen to this!</p>
<p><a href="music.ogg" type="application/ogg">Music</a></p>
</audio>


Is this correct (apart from the unsupported mp3 type)?
Is fallback content for an audio element considered block or inline? I find the spec confusing on this point.
Does the source element require a closing tag? Again, I find the spec confusing.

One specific validator tells me that I've done several things wrong:
  • The use of a P element (or any block level element for that matter) is not allowed inside an audio element
  • Some required thing is missing from the audio element


Now, I didn't see anything required but for the src attribute or one or more child source elements. Thus the validator confuses me. Is the validator correct and am I missing something crucial? Or is the validator out of synch with the latest html5 spec?

Here's the page I tried to have validated:
http://www.omegajunior.net/muziek/dierendag.html
OmegaJunior
<h6>
 
Posts: 9
Joined: Sun Oct 07, 2007 1:37 pm
Location: Netherlands

Postby zcorpan » Mon Oct 08, 2007 12:29 pm

zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden

Postby OmegaJunior » Mon Oct 08, 2007 1:06 pm

After some discussion in the #whatwg irc room it seems the spec is confusing indeed:

According to mentioned validator, the audio element seems to require fallback content, and the only content it allows is another embedded object (in my case, an embed element worked nicely).

It does not allow text, nor in-line phrase elements (span, em), nor block- or section elements. It also does not allow other audio elements but does allow multiple source elements.

Some of the problems I had were connected to me using the audio element inside a figure element, and trying to add block-level fallback content to the audio element. The combination of those three leads to undocumented behaviour.
OmegaJunior
<h6>
 
Posts: 9
Joined: Sun Oct 07, 2007 1:37 pm
Location: Netherlands


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests