HTML and CSS Reference
In-Depth Information
used:
frameborder
,
marginheight
,
marginwidth
, and
scrolling
. Addi-
tionally, the
longdesc
attribute has been dropped, which shouldn't be a loss, because
it never had adequate browser support anyway.
HTML5 has added a small number of attributes related to the ability to embed HTML
code snippets and pages that are
sandboxed
, meaning they are prevented from perform-
ing certain operations that could be used for nefarious purposes by third-party pieces of
code. The idea is to use inline frames as a way to secure pieces of code added dynamic-
ally to a web page from a third-party source, as might be done as part of the commenting
system on a blog or forum. The three attributes are
srcdoc
,
seamless
, and
sand-
box
.
Note
You may find that the new
iframe
attributes don't work in your preferred web
browser, because they have yet to gain much support among major browsers. As of this
writing,
sandbox
is the only one of the three new attributes to have support (in Safari
and Google Chrome). We hope further support will be quick to arrive, but as with any
new feature in HTML5, keep an eye out for changes to these attributes as the HTML5
specification is refined further in the months and years to come.
The
srcdoc
attribute allows snippets of HTML to be entered directly into the attrib-
ute's value, unlike
src
, which needs to be given a URL that points to another HTML
file, so for example:
<iframe
srcdoc="<p>This
text
is
in
an
inline
frame</p>"><p>This is regular text</p></iframe>
This code will create a snippet of HTML that will be inserted into an inline frame. If
the
srcdoc
and
src
attributes are present,
srcdoc
will override
src
, but
src
can
still be included and given a value so as to provide fallback content for when the
sr-
cdoc
attribute is not supported (which currently is the case in all major browsers).
The
seamless
attribute, which is a Boolean attribute, makes the included content
appear to be part of the containing document, meaning, for example, that links clicked in
the inline frame will load in the parent document instead of loading inside the
iframe
by default.
The last attribute,
sandbox
, may be treated as a Boolean attribute but does not ne-
cessarily need to be (as you'll see momentarily). When treated as a Boolean attribute, it
adds a number of security restrictions to the
iframe's
source content. These restric-
tions are as follows:
Search WWH ::
Custom Search