HTML and CSS Reference
In-Depth Information
The same fragment gives error messages in validators if it is written directly in the markup. The
iframe
version
of the button has problems too because it cannot be used in XHTML. It can be rewritten as an
object
(with the same
parameters), but then it stops working. Users of APIs and third-party software components often apply the previous
trick if they want their web page to validate.
■
providing markup code with
document.write
in Javascript is a hack that you should not use. the same
trick is applied for validating virtually any kind of otherwise incorrect markup that definitely cannot be accepted by real
web standardistas. the document will validate only because the content written in the external
.js
file is ignored by the
validator. this code is still not valid! how to provide such content without sacrificing either functionality or validity is an
open question in many cases, though.
Caution
Embedding YouTube Videos as Valid XHTML or HTML5
YouTube, the popular video sharing portal offers two types of embedding codes for videos:
object
element with parameters and an
embed
element. It supports Flash playback only.
•
The older-style embed code applies the
iframe
and supports both Flash and HTML5 video content.
•
The new embed code uses an
Under each video on YouTube, there is a Share button that provides a link to the current video with options
such as long link, HD link, and declaring a starting position for playback. After clicking on the Embed link, a text box
appears with the selected new-type embedding code ready for copying to the clipboard. Below that text box there are
further options for customizing the embedding code, such as declaring the size
4
or using the old-style embed code.
From the standardization point of view, both versions need some improvement.
In XHTML, the following issues should be addressed:
embed
element contained by the older-style embedding code is invalid in XHTML.
•
The
iframe
element used by the new-style embedding code cannot be used in XHTML 1.0
Strict or XHTML 1.1 (only in XHTML 1.0 Transitional, which should not be used). Moreover,
the
data
and
type
attributes should be provided to maximize interoperability (without them,
the embedding will not work under certain browsers). However, providing the
data
attribute
while preserving the
movie
parameter from the suggested embedding code ensures browser-
independence, because some rendering engines will use the outer declaration (the value of
the
data
attribute on the
object
element), and others will use the inner declaration (the value
of the
movie
parameter) to identify the resource URL (similarly to the Flash Satay method used
for Flash embedding covered in Chapter 9).
•
The
In HTML5, the following issues should be addressed:
frameborder
and
allowscreen
attributes
•
If you prefer the new-style embedding code, the
should not be used on the
iframe
element.
data
and
type
attributes are missing from the
object
element. Moreover, the
param
elements as well as the
embed
element should be closed using
the shorthand notation rather than the closing tags
</param>
and
</embed>
.
•
If you want to use the old-style code, the
4
The size can also be modified arbitrarily later in the markup when using the embedding code.
Search WWH ::
Custom Search