HTML5 - source element attributes question
What is the correct syntax for coding the type attribute and the codecs parameter for the source element. I keep seeing the following examples below.
Which is the correct 开发者_JAVA百科way to code the type attribute and the codecs parameter and why?
And whats with the single and double qoutes?
<source src=”instruction3.ogg” type="audio/ogg">
<source src="sfire3.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
<source src="sfire3.theora.ogv" type='video/ogg; codecs="theora, vorbis"'>
<source src="sfire3.webmvp8.webm" type="video/webm; codec="vp8, vorbis"'">
All of them (with a small exception for the last one) are correct. The type attribute holds information about to the video format (ogg/mp4/webm) and additionally the codec used in the video container.
The single and double quotes are used because using the same type of quotes as a string delimiter and inside the string doesn't work without escaping.
The last line should actually look like:
<source src="sfire3.webmvp8.webm" type='video/webm; codec="vp8, vorbis"'>
Note the removed double quote at the end.
The open book "Dive into HTML5" is an awesome reference for these kind of questions.
精彩评论