8000 csswg-drafts/cssom/Overview.html at b4cd6226a92bd1b6a96ad99106af0fa679988d41 · w3c/csswg-drafts · GitHub
Skip to content
8000

Latest commit

 

History

History
3060 lines (2405 loc) · 188 KB

File metadata and controls

3060 lines (2405 loc) · 188 KB
<!DOCTYPE html><html lang="en-US"><head>
<meta charset="utf-8">
<title>CSS Object Model (CSSOM)</title>
<style>
dl.switch { padding-left:2em }
dl.switch > dt { text-indent:-1.5em }
dl.switch > dt:before { content:'\21AA'; padding:0 0.5em 0 0; display:inline-block; width:1em; text-align:right; line-height:0.5em }
.atrisk::before { position:absolute; left:30px; margin-top:-8px; width:25px; height:25px; padding:0 4px 8px; border:1px solid; content:'At risk';
font-size:smaller; background:white; color:gray; border-radius:25px; text-align:center }
td { vertical-align:baseline }
td, th { border:solid }
table { border:hidden; border-collapse:collapse }
.propdef { font:inherit; line-height:2.3 }
.toc, .toc ol { list-style-type:none }
</style>
<link href="../default.css" rel="stylesheet">
<link href="https://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet">
</head>
<body class="draft">
<div class="head">
<!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="https://www.w3.org/Icons/w3c_home" width="72"></a></p>
<!--end-logo-->
<h1>CSS Object Model (CSSOM)</h1>
<h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 17 June 2013</h2>
<dl>
<dt>This Version:</dt>
<dd class="dontpublish"><a href="http://dev.w3.org/csswg/cssom/">http://dev.w3.org/csswg/cssom/</a></dd>
<dt class="dontpublish">Participate:</dt>
<dd class="dontpublish"><a href="mailto:www-style@w3.org?subject=%5Bcssom%5D%20">www-style@w3.org</a>
(<a href="http://lists.w3.org/Archives/Public/www-style/">archives</a>)</dd>
<dd class="dontpublish"><a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=CSS&amp;component=CSSOM">File a bug</a>
(<a href="https://www.w3.org/Bugs/Public/buglist.cgi?component=CSSOM&amp;product=CSS&amp;resolution=---">open bugs</a>)
<script async="" src="https://w3c-test.org/resources.whatwg.org/file-bug.js"></script></dd>
<dd class="dontpublish"><a href="irc://irc.w3.org:6665/css">IRC: #css on W3C</a></dd>
<dt class="dontpublish">Previous Version:</dt>
<dd class="dontpublish"><a href="http://www.w3.org/TR/2011/WD-cssom-20110712/">http://www.w3.org/TR/2011/WD-cssom-20110712/</a></dd>
<dd class="dontpublish"><a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/">http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/</a></dd>
<dt>Editors:</dt>
<dd><a>Simon Pieters</a>
(<a href="http://www.opera.com/">Opera Software ASA</a>)
&lt;<a href="mailto:simponp@opera.com">simonp@opera.com</a>&gt;</dd>
<dd><a href="http://www.w3.org/wiki/User:Gadams">Glenn Adams</a>
(<a href="http://www.cox.com/">Cox Communications, Inc.</a>)
&lt;<a href="mailto:glenn.adams@cox.com">glenn.adams@cox.com</a>&gt;</dd>
<dt>Previous Editor:</dt>
<dd><a href="http://annevankesteren.nl/">Anne van Kesteren</a>
(<a href="http://www.opera.com/">Opera Software ASA</a>)
&lt;<a href="mailto:annevk@opera.com">annevk@opera.com</a>&gt;</dd>
</dl>
<!--begin-copyright-->
<p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2013 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p>
<!--end-copyright-->
</div>
<hr class="top">
<h2 class="no-num no-toc" id="abstract">Abstract</h2>
<p>CSSOM defines APIs (including generic parsing and serialization rules)
for Media Queries, Selectors, and of course CSS itself.</p>
<h2 class="no-num no-toc" id="sotd">Status of This Document</h2>
<p>This is a public copy of the editors' draft. It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C or by the CSS Working Group. Don't cite
this document other than as work in progress.</p>
<p class="note">Implementers should note well that this specification is an ongoing effort to sort out
what has been widely implemented and deployed from <a class="informative" href="#refsDOM2STYLE">[DOM2STYLE]</a> as well as common extensions thereto, some details
of which are currently interoperable and others which are not currently interoperable. As this specification moves
forward, it is hoped that these differences will be resolved and an unambiguous and adequate consensus-based
specification will emerge.</p>
<p><em>This section describes the status of this document at the time of
its publication. Other documents may supersede this document. A list of
current W3C publications and the latest revision of this technical report
can be found in the
<a href="http://www.w3.org/TR/">W3C technical reports index at http://www.w3.org/TR/.</a></em>
<p class="dontpublish">This is the 17 June 2013 Editor's Draft of CSSOM. Please send comments to
<a href="mailto:www-style@w3.org?subject=%5Bcssom%5D%20">www-style@w3.org</a>
(<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
with <samp>[cssom]</samp> at the start of the subject line.
<p>This document was produced by a group operating under the
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>.
W3C maintains a
<a href="http://www.w3.org/2004/01/pp-impl/32061/status" rel="disclosure">public list of any patent disclosures</a>
made in connection with the deliverables of the group; that page also
includes instructions for disclosing a patent. An individual who has
actual knowledge of a patent which the individual believes contains
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a>
must disclose the information in accordance with
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.</p>
<h2 class="no-num no-toc" id="toc">Table of Contents</h2>
<!--begin-toc-->
<ol class="toc">
<li><a href="#introduction"><span class="secno">1 </span>Introduction</a></li>
<li><a href="#conformance"><span class="secno">2 </span>Conformance</a></li>
<li><a href="#terminology"><span class="secno">3 </span>Terminology</a>
<ol>
<li><a href="#common-serializing-idioms"><span class="secno">3.1 </span>Common Serializing Idioms</a></ol></li>
<li><a href="#media-queries"><span class="secno">4 </span>Media Queries</a>
<ol>
<li><a href="#parsing-media-queries"><span class="secno">4.1 </span>Parsing Media Queries</a></li>
<li><a href="#serializing-media-queries"><span class="secno">4.2 </span>Serializing Media Queries</a>
<ol>
<li><a href="#serializing-media-feature-values"><span class="secno">4.2.1 </span>Serializing Media Feature Values</a></ol></li>
<li><a href="#comparing-media-queries"><span class="secno">4.3 </span>Comparing Media Queries</a></li>
<li><a href="#the-medialist-interface"><span class="secno">4.4 </span>The <code title="">MediaList</code> Interface</a></ol></li>
<li><a href="#selectors"><span class="secno">5 </span>Selectors</a>
<ol>
<li><a href="#parsing-selectors"><span class="secno">5.1 </span>Parsing Selectors</a></li>
<li><a href="#serializing-selectors"><span class="secno">5.2 </span>Serializing Selectors</a></ol></li>
<li><a href="#css"><span class="secno">6 </span>CSS</a>
<ol>
<li><a href="#css-style-sheets"><span class="secno">6.1 </span>CSS Style Sheets</a>
<ol>
<li><a href="#the-stylesheet-interface"><span class="secno">6.1.1 </span>The <code title="">StyleSheet</code> Interface</a></li>
<li><a href="#the-cssstylesheet-interface"><span class="secno">6.1.2 </span>The <code title="">CSSStyleSheet</code> Interface</a></ol></li>
<li><a href="#css-style-sheet-collections"><span class="secno">6.2 </span>CSS Style Sheet Collections</a>
<ol>
<li><a href="#the-http-default-style-header"><span class="secno">6.2.1 </span>The HTTP <code title="">Default-Style</code> Header</a></li>
<li><a href="#the-stylesheetlist-interface"><span class="secno">6.2.2 </span>The <code title="">StyleSheetList</code> Interface</a></li>
<li><a href="#extensions-to-the-document-interface"><span class="secno">6.2.3 </span>Extensions to the <code title="">Document</code> Interface</a></li>
<li><a href="#interaction-with-the-user-interface"><span class="secno">6.2.4 </span>Interaction with the User Interface</a>
<ol>
<li><a href="#persisting-the-selected-css-style-sheet-set"><span class="secno">6.2.4.1 </span>Persisting the selected CSS style sheet set</a></ol></li>
<li><a href="#examples"><span class="secno">6.2.5 </span>Examples</a></ol></li>
<li><a href="#style-sheet-association"><span class="secno">6.3 </span>Style Sheet Association</a>
<ol>
<li><a href="#the-linkstyle-interface"><span class="secno">6.3.1 </span>The <code title="">LinkStyle</code> Interface</a></li>
<li><a href="#requirements-on-specifications"><span class="secno">6.3.2 </span>Requirements on specifications</a></li>
<li><a href="#requirements-on-user-agents-implementing-the-xml-stylesheet-processing-instruction"><span class="secno">6.3.3 </span>Requirements on User Agents Implementing the xml-stylesheet processing instruction</a></li>
<li><a href="#requirements-on-user-agents-implementing-the-http-link-header"><span class="secno">6.3.4 </span>Requirements on User Agents Implementing the HTTP
<code title="">Link</code> Header</a></ol></li>
<li><a href="#css-rules"><span class="secno">6.4 </span>CSS Rules</a>
<ol>
<li><a href="#the-cssrulelist-interface"><span class="secno">6.4.1 </span>The <code title="">CSSRuleList</code> Interface</a></li>
<li><a href="#the-cssrule-interface"><span class="secno">6.4.2 </span>The <code title="">CSSRule</code> Interface</a></li>
<li><a href="#the-cssstylerule-interface"><span class="secno">6.4.3 </span>The <code title="">CSSStyleRule</code> Interface</a></li>
<li><a href="#the-csscharsetrule-interface"><span class="secno">6.4.4 </span>The <code title="">CSSCharsetRule</code> Interface</a></li>
<li><a href="#the-cssimportrule-interface"><span class="secno">6.4.5 </span>The <code title="">CSSImportRule</code> Interface</a></li>
<li><a href="#the-cssgroupingrule-interface"><span class="secno">6.4.6 </span>The <code title="">CSSGroupingRule</code> Interface</a></li>
<li><a href="#the-cssmediarule-interface"><span class="secno">6.4.7 </span>The <code title="">CSSMediaRule</code> Interface</a></li>
<li><a href="#the-cssfontfacerule-interface"><span class="secno">6.4.8 </span>The <code title="">CSSFontFaceRule</code> Interface</a></li>
<li><a href="#the-csspagerule-interface"><span class="secno">6.4.9 </span>The <code title="">CSSPageRule</code> Interface</a></li>
<li><a href="#the-cssnamespacerule-interface"><span class="secno">6.4.10 </span>The <code title="">CSSNamespaceRule</code> Interface</a></ol></li>
<li><a href="#css-declaration-blocks"><span class="secno">6.5 </span>CSS Declaration Blocks</a>
<ol>
<li><a href="#the-cssstyledeclaration-interface"><span class="secno">6.5.1 </span>The <code title="">CSSStyleDeclaration</code> Interface</a></ol></li>
<li><a href="#css-values"><span class="secno">6.6 </span>CSS Values</a>
<ol>
<li><a href="#parsing-css-values"><span class="secno">6.6.1 </span>Parsing CSS Values</a></li>
<li><a href="#serializing-css-values"><span class="secno">6.6.2 </span>Serializing CSS Values</a>
<ol>
<li><a href="#examples-0"><span class="secno">6.6.2.1 </span>Examples</a></ol></ol></ol></li>
<li><a href="#dom-access-to-css-declaration-blocks"><span class="secno">7 </span>DOM Access to CSS Declaration Blocks</a>
<ol>
<li><a href="#the-elementcssinlinestyle-interface"><span class="secno">7.1 </span>The <code>ElementCSSInlineStyle</code> Interface</a></li>
<li><a href="#extensions-to-the-window-interface"><span class="secno">7.2 </span>Extensions to the <code title="">Window</code> Interface</a></li>
<li><a href="#the-getstyleutils-interface"><span class="secno">7.3 </span>The <code title="">GetStyleUtils</code> Interface</a></li>
<li><a href="#extensions-to-the-element-interface"><span class="secno">7.4 </span>Extensions to the <code title="">Element</code> Interface</a></li>
<li><a href="#the-pseudoelement-interface"><span class="secno">7.5 </span>The <code title="">PseudoElement</code> Interface</a></ol></li>
<li><a href="#resolved-values"><span class="secno">8 </span>Resolved Values</a></li>
<li><a href="#iana-considerations"><span class="secno">9 </span>IANA Considerations</a>
<ol>
<li><a href="#default-style"><span class="secno">9.1 </span><code title="">Default-Style</code></a></ol></li>
<li><a class="no-num" href="#references">References</a></li>
<li><a class="no-num" href="#change-history">Change History</a>
<ol>
<li><a class="no-num" href="#changes-from-dom-2-style">Changes From DOM-2 Style</a></ol></li>
<li><a class="no-num" href="#acknowledgments">Acknowledgments</a></ol>
<!--end-toc-->
<h2 id="introduction"><span class="secno">1 </span>Introduction</h2>
<p>This document formally specifies the core features of the CSS Object Model (CSSOM). Other documents in the CSSOM family of specifications
as well as other CSS related specifications define extensions to these core features.</p>
<p>The core features of the CSSOM are oriented towards providing basic capabilities to author-defined scripts to permit access to
and manipulation of style related state information and processes.</p>
<p>The features defined below are fundamentally based on prior specifications of the W3C DOM Working Group, primarily
<a class="informative" href="#refsDOM2STYLE">[DOM2STYLE]</a>. The purposes of the present document are (1) to improve on that prior work by providing
more technical specificity (so as to improve testability and interoperability), (2) to deprecate or remove certain less-widely implemented
features no longer considered to be essential in this context, and (3) to newly specify certain extensions that have been
or expected to be widely implemented.</p>
<p>A full list of the changes to API signatures can be found in <a href="#changes-from-dom-2-style"><cite>Changes from DOM-2 Style</cite></a>.</p>
<h2 id="conformance"><span class="secno">2 </span>Conformance</h2>
<p>All diagrams, examples, and notes in this specification are
non-normative, as are all sections explicitly marked non-normative.
Everything else in this specification is normative.
<p>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL
NOT",--> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" in the normative parts of this document are to be
interpreted as described in RFC2119. For readability, these words do
not appear in all uppercase letters in this specification.
<a href="#refsRFC2119">[RFC2119]</a>
<p>Requirements phrased in the imperative as part of algorithms
(such as "strip any leading space characters" or "return false and
terminate these steps") are to be interpreted with the meaning of the
key word ("must", "should", "may", etc) used in introducing the
algorithm.
<p>Conformance requirements phrased as algorithms or specific steps
may be implemented in any manner, so long as the end result is
equivalent. (In particular, the algorithms defined in this
specification are intended to be easy to follow, and not intended to
be performant.)
<p id="hardwareLimitations">User agents may impose
implementation-specific limits on otherwise unconstrained inputs,
e.g. to prevent denial of service attacks, to guard against running
out of memory, or to work around platform-specific limitations.
<p>When a method or an attribute is said to call another method or attribute, the user agent must invoke its internal API for that attribute or method so that
e.g. the author can't change the behavior by overriding attributes or methods with custom properties or functions in ECMAScript.
<p>Unless otherwise stated, string comparisons are done in a
<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#case-sensitive">case-sensitive</a> manner.
<h2 id="terminology"><span class="secno">3 </span>Terminology</h2>
<p>This specification employs certain terminology from the following documents:
<cite>DOM</cite>,
<cite>HTML</cite>,
<cite>CSS Syntax</cite>,
<cite>URL</cite>,
<cite>Fetch</cite>,
<cite>Associating Style Sheets with XML documents</cite>
and
<cite>XML</cite>.
<a href="#refsDOM">[DOM]</a>
<a href="#refsHTML">[HTML]</a>
<a href="#refsCSSSYNTAX">[CSSSYNTAX]</a>
<a href="#refsURL">[URL]</a>
<a href="#refsFETCH">[FETCH]</a>
<a href="#refsXMLSS">[XMLSS]</a>
<a href="#refsXML">[XML]</a>
<p>When this specification talks about object
<code title=""><var>A</var></code> where <code title=""><var>A</var></code> is actually an interface, it generally means an object implementing interface
<code title=""><var>A</var></code>.</p>
<p>The terms <dfn id="whitespace">whitespace</dfn>, <dfn id="ignored">ignored</dfn>, <dfn id="specified-value">specified value</dfn>, <dfn id="computed-value">computed value</dfn> and <dfn id="used-value">used value</dfn> are defined in CSS.
<a href="#refsCSS">[CSS]</a>
<p>The terms <dfn id="simple-selector">simple selector</dfn>, <dfn id="sequence-of-simple-selectors">sequence of simple selectors</dfn>, <dfn id="universal-selector">universal selector</dfn> and <dfn id="group-of-selectors">group of selectors</dfn> are defined in
Selectors. <a href="#refsSELECTORS">[SELECTORS]</a>
<p>The terms <dfn id="namespace-prefix">namespace prefix</dfn> and <dfn id="default-namespace">default namespace</dfn> are defined in CSS Namespaces Module. <a href="#refsCSSNAMESPACES">[CSSNAMESPACES]</a>
<p>The term <dfn id="list-of-css-page-selectors">list of CSS page selectors</dfn> refers to the comma-separated list of page selectors, as defined in CSS Paged Media Module.
<a href="#refsCSSPAGE">[CSSPAGE]</a>
<p>The terms <dfn id="set">set</dfn> and <dfn id="clear">clear</dfn> to refer to the true and
false values of binary flags or variables, respectively. These terms are also used as verbs in which case they refer to
mutating some value to make it true or false, respectively.</p>
<p>The term <dfn id="supported-styling-language">supported styling language</dfn> refers to CSS.
<p class="note">If another styling language becomes supported in user agents, this specification is expected to be updated as necessary.
<p>The terms <dfn id="::before-pseudo-element">::before pseudo-element</dfn> and <dfn id="::after-pseudo-element">::after pseudo-element</dfn> refer to the :before and :after pseudo-elements in CSS, except in this
specification the pseudo-elements are assumed to exist for all elements even if no box is generated for them. <a href="#refsCSS">[CSS]</a>
<h3 id="common-serializing-idioms"><span class="secno">3.1 </span>Common Serializing Idioms</h3>
<p>To <dfn id="escape-a-character">escape a character</dfn> means to create a string of
"<code title="">\</code>" (U+005C), followed by the character.</p>
<p>To <dfn id="escape-a-character-as-code-point">escape a character as code point</dfn> means to create a
string of "<code title="">\</code>" (U+005C), followed by the Unicode code point as
the smallest possible number of hexadecimal digits in the range 0-9 a-f
(U+0030 to U+0039 and U+0061 to U+0066) to represent the code point in
base 16, followed by a single SPACE (U+0020).</p>
<p>To <dfn id="serialize-an-identifier">serialize an identifier</dfn> means to create a string represented
by the concatenation of, for each character of the identifier:</p>
<ul>
<li>If the character is NULL (U+0000), then <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> an
<code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#invalidcharactererror">InvalidCharacterError</a></code> exception and terminate these steps.</li>
<li>If the character is in the range [\1-\1f] (U+0001 to U+001F) or
[\7f-\9f] (U+007F to U+009F), then the character
<a href="#escape-a-character-as-code-point" title="escape a character as code point">escaped as code point</a>.</li>
<li>If the character is the first character and is in the range [0-9]
(U+0030 to U+0039), then the character
<a href="#escape-a-character-as-code-point" title="escape a character as code point">escaped as code point</a>.</li>
<li>If the character is the second character and is in the range [0-9]
(U+0030 to U+0039) and the first character is a "<code title="">-</code>"
(U+002D), then the character
<a href="#escape-a-character-as-code-point" title="escape a character as code point">escaped as code point</a>.</li>
<li>If the character is the second character and is "<code title="">-</code>"
(U+002D) and the first character is "<code title="">-</code>" as well, then the
<a href="#escape-a-character" title="escape a character">escaped</a> character.</li>
<li>If the character is not handled by one of the above rules and is
greater than or equal to U+0080, is "<code title="">-</code>" (U+002D) or
"<code title="">_</code>" (U+005F), or is in one of the ranges [0-9] (U+0030 to
U+0039), [A-Z] (U+0041 to U+005A), or [a-z] (U+0061 to U+007A), then the character
itself.</li>
<li>Otherwise, the <a href="#escape-a-character" title="escape a character">escaped</a>
character.</li>
</ul>
<p>To <dfn id="serialize-a-string">serialize a string</dfn> means to create a string represented
by '"' (U+0022), followed by the result of applying the rules
below to each character of the given string, followed by
'"' (U+0022):</p>
<ul>
<li>If the character is NULL (U+0000), then <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> an
<code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#invalidcharactererror">InvalidCharacterError</a></code> exception and terminate these steps.</li>
<li>If the character is in the range [\1-\1f] (U+0001 to U+001F) or [\7f-\9f] (U+007F to
U+009F), the character <a href="#escape-a-character-as-code-point" title="escape a character as code point">escaped as code point</a>.</li>
<li>If the character is '"' (U+0022) or "<code title="">\</code>"
(U+005C), the <a href="#escape-a-character" title="escape a character">escaped</a> character.</li>
<li>Otherwise, the character itself.</li>
</ul>
<p class="note">"<code title="">'</code>" (U+0027) is not escaped because strings
are always serialized with '"' (U+0022).</p>
<p>To <dfn id="serialize-a-url">serialize a URL</dfn> means to create a string represented by
"<code title="">url(</code>", followed by the
<a href="#serialize-a-string" title="serialize a string">string escaped</a> value of the given
string, followed by "<code title="">)</code>".</p>
<p>To <dfn id="serialize-a-comma-separated-list">serialize a comma-separated list</dfn> concatenate all items of
the list in list order while separating them by "<code title="">, </code>", i.e.,
COMMA (U+002C) followed by a single SPACE (U+0020).</p>
<p>To <dfn id="serialize-a-whitespace-separated-list">serialize a whitespace-separated list</dfn> concatenate all
items of the list in list order while separating them by "<code title=""> </code>", i.e.,
a single SPACE (U+0020).</p>
<p class="note">When serializing a list according to the above rules,
extraneous whitespace is not inserted prior to the first item or subsequent to
the last item. Unless otherwise specified, an empty list is serialized as the
empty string.</p>
<h2 id="media-queries"><span class="secno">4 </span>Media Queries</h2>
<p>Media queries are defined by the Media Queries specification. This
section defines various concepts around media queries, including their API
and serialization form.</p>
<!-- XXX ref -->
<h3 id="parsing-media-queries"><span class="secno">4.1 </span>Parsing Media Queries</h3>
<p>To
<dfn id="parse-a-media-query-list">parse a media query list</dfn> for a
given string <var>s</var> into a media query list is defined in
the Media Queries specification. Return the list of one or more media
queries that the algorithm defined there gives.</p> <!-- XXX ref -->
<p class="note">A media query that ends up being "ignored" will turn
into "<code title="">not all</code>".</p>
<p>To
<dfn id="parse-a-media-query">parse a media query</dfn> for a given string
<var>s</var> means to follow the
<a href="#parse-a-media-query-list">parse a media query list</a> steps and return null if more
than one media query is returned or a media query if a
single media query is returned.</p>
<p class="note">Again, a media query that ends up being "ignored" will
turn into "<code title="">not all</code>".</p>
<h3 id="serializing-media-queries"><span class="secno">4.2 </span>Serializing Media Queries</h3>
<p>To
<dfn id="serialize-a-media-query-list">serialize a media query list</dfn>
run these steps:</p>
<ol>
<li><p>If the media query list is empty return the empty string and
terminate these steps.</li>
<li><p><a href="#serialize-a-media-query" title="serialize a media query">Serialize</a> each
media query in the list of media queries, sort them in lexicographical
order, and then
<a href="#serialize-a-comma-separated-list" title="serialize a comma-separated list">serialize</a> the
list.</li>
</ol>
<p>To
<dfn id="serialize-a-media-query">serialize a media query</dfn> let
<var>s</var> be the empty string, run the steps below, and
finally return <var>s</var>:</p>
<ol>
<li><p>If the media query is negated append "<code title="">not</code>", followed
by a single SPACE (U+0020), to <var>s</var>.</li>
<li><p>Let <var>type</var> be the media type of the media query,
<a href="#serialize-an-identifier" title="serialize an identifier">escaped</a> and
<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#converted-to-ascii-lowercase">converted to ASCII lowercase</a>.</li>
<li><p>If the media query does not contain media features append
<var>type</var>, to <var>s</var>,
then return <var>s</var> and terminate this algorithm.</li>
<li><p>If <var>type</var> is not "<code title="">all</code>" or if the
media query is negated append <var>type</var>, followed by a
single SPACE (U+0020), followed by "<code title="">and</code>", followed by a single SPACE
(U+0020), to <var>s</var>.</li>
<li><p>Sort the media features in lexicographical order.</li>
<li>
<p>Then, for each media feature:</p>
<ol>
<li><p>Append a "<code title="">(</code>" (U+0028), followed by the media feature
name, <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#converted-to-ascii-lowercase">converted to ASCII lowercase</a>,
to <var>s</var>.</li>
<li><p>If a value is given append a "<code title="">:</code>" (U+003A), followed
by a single SPACE (U+0020), followed by the
<a href="#serialize-a-media-feature-value" title="serialize a media feature value">serialized media feature value</a>,
to <var>s</var>.</li>
<li><p>Append a "<code title="">)</code>" (U+0029) to
<var>s</var>.</li>
<li><p>If this is not the last media feature append a single SPACE (U+0020),
followed by "<code title="">and</code>", followed by a single SPACE (U+0020), to
<var>s</var>.</li>
</ol>
</li>
</ol>
<div class="example">
<p>Here are some examples of input (first column) and output (second
column):</p>
<table>
<thead>
<tr><th>Input<th>Output
<tbody>
<tr>
<td><pre>not screen and (min-WIDTH:5px) AND (max-width:40px)</pre>
<td><pre>not screen and (max-width: 40px) and (min-width: 5px)</pre>
<tr>
<td><pre>all and (color) and (color)</pre>
<td><pre>(color)</pre>
</table>
</div>
<h4 id="serializing-media-feature-values"><span class="secno">4.2.1 </span>Serializing Media Feature Values</h4>
<p class="issue">This should probably be done in terms of mapping it to
serializing CSS values as media features are defined in terms of CSS
values after all.</p>
<p>To <dfn id="serialize-a-media-feature-value">serialize a media feature value</dfn>
named <var>v</var> locate <var>v</var> in the first
column of the table below and use the serialization format described in
the second column:</p>
<table>
<tr>
<th>Media Feature
<th>Serialization
<tr>
<td>'width'
<td>...
<tr>
<td>'height'
<td>...
<tr>
<td>'device-width'
<td>...
<tr>
<td>'device-height'
<td>...
<tr>
<td>'orientation'
<td>
<p>If the value is 'portrait': "<code title="">portrait</code>".</p>
<p>If the value is 'landscape': "<code title="">landscape</code>".</p>
<tr>
<td>'aspect-ratio'
<td>...
<tr>
<td>'device-aspect-ratio'
<td>...
<tr>
<td>'color'
<td>...
<tr>
<td>'color-index'
<td>...
<tr>
<td>'monochrome'
<td>...
<tr>
<td>'resolution'
<td>...
<tr>
<td>'scan'
<td>
<p>If the value is 'progressive': "<code title="">progressive</code>".</p>
<p>If the value is 'interlace': "<code title="">interlace</code>".</p>
<tr>
<td>'grid'
<td>...
</table>
<p>Other specifications can extend this table and vendor-prefixed media
features can have custom serialization formats as well.</p>
<h3 id="comparing-media-queries"><span class="secno">4.3 </span>Comparing Media Queries</h3>
<p>To
<dfn id="compare-media-queries">compare media queries</dfn>
<var>m1</var> and <var>m2</var> means to
<a href="#serialize-a-media-query" title="serialize a media query">serialize</a> them both and
return true if they are a
<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#case-sensitive">case-sensitive</a> match and false if they
are not.</p>
<h3 id="the-medialist-interface"><span class="secno">4.4 </span>The <code title="">MediaList</code> Interface</h3>
<!--
//
// All members defined since DOM-2 Style. The only differences are:
//
// 1. addition of stringifier qualifier on mediaText
// 2. addition of getter qualifier on item
// 3. removal of raises(DOMException) from {append,delete}Medium
//
-->
<p>An object that implements the <code><a href="#medialist">MediaList</a></code> interface has an associated <dfn id="collection-of-media-queries">collection of media queries</dfn>.</p>
<pre class="idl">[<a href="#dom-medialist" title="dom-MediaList">Constructor</a>(DOMString text)]
interface <dfn id="medialist">MediaList</dfn> {
[TreatNullAs=EmptyString] stringifier attribute DOMString <a href="#dom-medialist-mediatext" title="dom-MediaList-mediaText">mediaText</a>;
readonly attribute unsigned long <a href="#dom-medialist-length" title="dom-MediaList-length">length</a>;
getter DOMString <a href="#dom-medialist-item" title="dom-MediaList-item">item</a>(unsigned long index);
void <a href="#dom-medialist-appendmedium" title="dom-MediaList-appendMedium">appendMedium</a>(DOMString medium);
void <a href="#dom-medialist-deletemedium" title="dom-MediaList-deleteMedium">deleteMedium</a>(DOMString medium);
};</pre>
<p>The object's <a class="external" data-anolis-spec="webidl" href="http://dev.w3.org/2006/webapi/WebIDL/#dfn-supported-property-indices">supported property indices</a> are the numbers in the range zero to one less than the number of media queries
in the <a href="#collection-of-media-queries">collection of media queries</a> represented by the collection. If there are no such media queries, then there are no
<a class="external" data-anolis-spec="webidl" href="http://dev.w3.org/2006/webapi/WebIDL/#dfn-supported-property-indices">supported property indices</a>.
<p>When the <dfn id="dom-medialist" title="dom-MediaList"><code>MediaList(<var>text</var>)</code></dfn> constructor is invoked, the <a href="#create-a-medialist-object">create a <code>MediaList</code>
object</a> steps must be run with the string <var>text</var>.</p>
<p>To <dfn id="create-a-medialist-object">create a <code>MediaList</code> object</dfn> with a string <var>text</var>, run the following steps:
<ol>
<li><p>Create a new <code><a href="#medialist">MediaList</a></code> object.</li>
<li><p>Set its <code title="dom-MediaList-mediaText"><a href="#dom-medialist-mediatext">mediaText</a></code> attribute to <var>text</var>.</li>
<li><p>Return the newly created <code><a href="#medialist">MediaList</a></code> object.</li>
</ol>
<p>The <dfn id="dom-medialist-mediatext" title="dom-MediaList-mediaText"><code>mediaText</code></dfn> attribute, on getting, must return a
<a href="#serialize-a-media-query-list" title="serialize a media query list">serialization</a> of the <a href="#collection-of-media-queries">collection of media queries</a>.</p>
<p>Setting the <code title="dom-MediaList-mediaText"><a href="#dom-medialist-mediatext">mediaText</a></code> attribute must run these steps:
<ol>
<li><p>Empty the <a href="#collection-of-media-queries">collection of media queries</a>.</li>
<li><p>If the given value is the empty string terminate these steps.</li>
<li><p>Append all the media queries as a result of <a href="#parse-a-media-query-list" title="parse a media query list">parsing</a> the given
value to the <a href="#collection-of-media-queries">collection of media queries</a>.</li>
</ol>
<p>The <dfn id="dom-medialist-item" title="dom-MediaList-item"><code>item(<var>index</var>)</code></dfn> method must return the media query in the <a href="#collection-of-media-queries">collection of media
queries</a> given by <var>index</var>, or null, if <var>index</var> is greater than or equal to the number of media queries in the
<a href="#collection-of-media-queries">collection of media queries</a>.</p>
<p>The <dfn id="dom-medialist-length" title="dom-MediaList-length"><code>length</code></dfn> attribute must return the number of media queries in the <a href="#collection-of-media-queries">collection of media
queries</a>.</p>
<p>The <dfn id="dom-medialist-appendmedium" title="dom-MediaList-appendMedium"><code>appendMedium(<var>medium</var>)</code></dfn> method must run these steps:</p>
<ol>
<li><p>Let <var>m</var> be the result of <a href="#parse-a-media-query" title="parse a media query">parsing</a> the given value.</li>
<li><p>If <var>m</var> is null terminate these steps.</li>
<li><p>If <a href="#compare-media-queries" title="compare media queries">comparing</a> <var>m</var> with any of the media queries in the
<a href="#collection-of-media-queries">collection of media queries</a> returns true terminate these steps.</li>
<li><p>Append <var>m</var> to the <a href="#collection-of-media-queries">collection of media queries</a>.</li>
</ol>
<p>The <dfn id="dom-medialist-deletemedium" title="dom-MediaList-deleteMedium"><code>deleteMedium(<var>medium</var>)</code></dfn> method must run these steps:</p>
<ol>
<li><p>Let <var>m</var> be the result of <a href="#parse-a-media-query" title="parse a media query">parsing</a> the given value.</li>
<li><p>If <var>m</var> is null terminate these steps.</li>
<li><p>Remove any media query from the <a href="#collection-of-media-queries">collection of media queries</a> for which
<a href="#compare-media-queries" title="compare media queries">comparing</a> the media query with <var>m</var> returns true.</li>
</ol>
<h2 id="selectors"><span class="secno">5 </span>Selectors</h2>
<p>Selectors are defined in the Selectors specification. This section
mainly defines how to serialize them.</p> <!-- XXX ref -->
<!-- XXX ref universal selector etc? some are in <span> some not -->
<h3 id="parsing-selectors"><span class="secno">5.1 </span>Parsing Selectors</h3>
<p>To
<dfn id="parse-a-group-of-selectors">parse a group of selectors</dfn>
means to parse the value using the <code title="">selectors_group</code>
production defined in the Selectors specification and return either a
group of selectors if parsing did not fail or null if parsing did
fail.</p> <!-- XXX ref -->
<h3 id="serializing-selectors"><span class="secno">5.2 </span>Serializing Selectors</h3>
<!-- http://dump.testsuite.org/2009/cssom/serializing-selectors.htm -->
<p>To
<dfn id="serialize-a-group-of-selectors">serialize a group of selectors</dfn>
<a href="#serialize-a-selector" title="serialize a selector">serialize</a> each selector in the
group of selectors and then
<a href="#serialize-a-comma-separated-list" title="serialize a comma-separated list">serialize</a> the
group.</p>
<p>To <dfn id="serialize-a-selector">serialize a selector</dfn> let
<var>s</var> be the empty string, run the steps below for each
part of the chain of the selector, and finally return
<var>s</var>:</p>
<ol>
<li><p>If there is only one <a href="#simple-selector">simple selector</a> in the
<a href="#sequence-of-simple-selectors">sequence of simple selectors</a> which is a
<a href="#universal-selector">universal selector</a>, append the result of
<a href="#serialize-a-simple-selector" title="serialize a simple selector">serializing</a> the
<a href="#universal-selector">universal selector</a> to <var>s</var>.</li>
<li><p>Otherwise, for each <a href="#simple-selector">simple selector</a> in the
<a href="#sequence-of-simple-selectors">sequence of simple selectors</a> that is not a
universal selector of which the
<a href="#namespace-prefix">namespace prefix</a> maps to a namespace that is not the
<a href="#default-namespace">default namespace</a>
<a href="#serialize-a-simple-selector" title="serialize a simple selector">serialize</a> the
<a href="#simple-selector">simple selector</a> and append the result to
<var>s</var>.</li>
<li><p>If this is not the last part of the chain of the selector append a
single SPACE (U+0020), followed by the combinator
"<code title="">&gt;</code>",
"<code title="">+</code>", or
"<code title="">~</code>"
as appropriate, followed by another single SPACE (U+0020) if the combinator was
not whitespace, to <var>s</var>.</li>
<li><p>If this is the last part of the chain of the selector and there is
a pseudo-element, append "<code title="">::</code>" followed by the name of the
pseudo-element, to <var>s</var>.</li>
</ol>
<p>To
<dfn id="serialize-a-simple-selector">serialize a simple selector</dfn>
let <var>s</var> be the empty string, run the steps below, and
finally return <var>s</var>:</p>
<dl class="switch">
<dt>type selector</dt>
<dt>universal selector</dt>
<dd>
<ol>
<li><p>If the <a href="#namespace-prefix">namespace prefix</a> maps to a namespace that is
not the <a href="#default-namespace">default namespace</a> and is not the
null namespace (not in a namespace) append the
<a href="#serialize-an-identifier" title="serialize an identifier">escaped</a>
<a href="#namespace-prefix">namespace prefix</a>, followed by a "<code title="">|</code>" (U+007C)
to <var>s</var>.</li>
<li><p>If the <a href="#namespace-prefix">namespace prefix</a> maps to a namespace that is
the null namespace (not in a namespace) append
"<code title="">|</code>" (U+007C) to <var>s</var>.</li>
<!-- This includes |* -->
<li><p>If this is a type selector append the
<a href="#serialize-an-identifier" title="serialize an identifier">escaped</a> element name to
<var>s</var>.</li>
<li><p>If this is a universal selector append "<code title="">*</code>" (U+002A)
to <var>s</var>.</li>
</ol>
</dd>
<dt>attribute selector</dt>
<dd>
<ol>
<li><p>Append "<code title="">[</code>" (U+005B) to
<var>s</var>.</li>
<li><p>If the <a href="#namespace-prefix">namespace prefix</a> maps to a namespace that is
not the null namespace (not in a namespace) append the
<a href="#serialize-an-identifier" title="serialize an identifier">escaped</a>
<a href="#namespace-prefix">namespace prefix</a>, followed by a "<code title="">|</code>" (U+007C)
to <var>s</var>.</li>
<li><p>Append the <a href="#serialize-an-identifier" title="serialize an identifier">escaped</a>
attribute name to <var>s</var>.</li>
<li><p>If there is an attribute value specified, append
"<code title="">=</code>",
"<code title="">~=</code>",
"<code title="">|=</code>",
"<code title="">^=</code>",
"<code title="">$=</code>", or
"<code title="">*=</code>"
as appropriate (depending on the type of attribute selector), followed
by the <a href="#serialize-a-string" title="serialize a string">string escaped</a>
attribute value, to <var>s</var>.</li>
<li><p>Append "<code title="">]</code>" (U+005D) to
<var>s</var>.</li>
</ol>
</dd>
<dt>class selector</dt>
<dd><p>Append a "<code title="">.</code>" (U+002E), followed by the
<a href="#serialize-an-identifier" title="serialize an identifier">escaped</a> class name to
<var>s</var>.</dd>
<dt>ID selector</dt>
<dd><p>Append a "<code title="">#</code>" (U+0023), followed by the
<a href="#serialize-an-identifier" title="serialize an identifier">escaped</a> ID to
<var>s</var>.</dd>
<dt>pseudo-class</dt>
<dd>
<p>If the pseudo-class does not accept arguments append
"<code title="">:</code>" (U+003A), followed by the name of the pseudo-class, to
<var>s</var>.</p>
<p>Otherwise, append "<code title="">:</code>" (U+003A), followed by the name of
the pseudo-class, followed by "<code title="">(</code>" (U+0028), followed by the
value of the pseudo-class argument determined as per below, followed by
"<code title="">)</code>" (U+0029), to <var>s</var>.</p>
<dl class="switch">
<dt><code title="">:lang()</code></dt>
<dd><p>The <a href="#serialize-an-identifier" title="serialize an identifier">escaped</a>
value.</dd>
<dt><code title="">:nth-child()</code></dt>
<dt><code title="">:nth-last-child()</code></dt>
<dt><code title="">:nth-of-type()</code></dt>
<dt><code title="">:nth-last-of-type()</code></dt>
<dd><p>The result of serializing the value using the rules for <a class="external" data-anolis-spec="csssyntax" href="http://dev.w3.org/csswg/css-syntax/#serializing-anb">serializing &lt;an+b&gt;</a>.
<dt><code title="">:not()</code></dt>
<dd><p>The result of serializing the value using the rules for
<a href="#serialize-a-group-of-selectors" title="serialize a group of selectors">serializing a group of selectors</a>.</dd>
</dl>
</dd>
</dl>
<h2 id="css"><span class="secno">6 </span>CSS</h2>
<h3 id="css-style-sheets"><span class="secno">6.1 </span>CSS Style Sheets</h3>
<!-- XXX
element inserted into the DOM, style sheet created, element removed from
the DOM, what happens to StyleSheet?
-->
<p>A <dfn id="css-style-sheet">CSS style sheet</dfn> is an abstract concept that
represents a style sheet as defined by the CSS specification. In the CSSOM a
<a href="#css-style-sheet">CSS style sheet</a> is represented as a <code><a href="#cssstylesheet">CSSStyleSheet</a></code> object. A
<a href="#css-style-sheet">CSS style sheet</a> has a number of associated state items:</p>
<dl>
<dt><dfn id="concept-css-style-sheet-type" title="concept-css-style-sheet-type">type</dfn></dt>
<dd><p>The literal string "<code title="">text/css</code>".</dd>
<dt><dfn id="concept-css-style-sheet-location" title="concept-css-style-sheet-location">location</dfn></dt>
<dd><p>Specified when created. The <a class="external" data-anolis-spec="url" href="http://url.spec.whatwg.org/#concept-absolute-url" title="concept-absolute-url">absolute URL</a> of the first request of the
<a href="#css-style-sheet">CSS style sheet</a> or null if the <a href="#css-style-sheet">CSS style sheet</a> was
embedded. Does not change during the lifetime of the <a href="#css-style-sheet">CSS style sheet</a>.</dd>
<dt><dfn id="concept-css-style-sheet-parent-css-style-sheet" title="concept-css-style-sheet-parent-css-style-sheet">parent CSS style sheet</dfn></dt>
<dd><p>Specified when created. The <a href="#css-style-sheet">CSS style sheet</a> that is the parent of the
<a href="#css-style-sheet">CSS style sheet</a> or null if there is no associated parent.</dd>
<dt><dfn id="concept-css-style-sheet-owner-node" title="concept-css-style-sheet-owner-node">owner node</dfn></dt>
<dd><p>Specified when created. The DOM node associated with the <a href="#css-style-sheet">CSS style sheet</a> or
null if there is no associated DOM node.</dd>
<dt><dfn id="concept-css-style-sheet-owner-css-rule" title="concept-css-style-sheet-owner-css-rule">owner CSS rule</dfn></dt>
<dd><p>Specified when created. The <a href="#css-rule">CSS rule</a> in the <a href="#concept-css-style-sheet-parent-css-style-sheet" title="concept-css-style-sheet-parent-css-style-sheet">parent CSS style sheet</a>
that caused the inclusion of the <a href="#css-style-sheet">CSS style sheet</a> or null if
there is no associated rule.</dd>
<dt><dfn id="concept-css-style-sheet-media" title="concept-css-style-sheet-media">media</dfn></dt>
<dd>
<p>Specified when created. The <code><a href="#medialist">MediaList</a></code> object associated with the
<a href="#css-style-sheet">CSS style sheet</a>.</p>
<p>If this property is specified to a string, the <a href="#concept-css-style-sheet-media" title="concept-css-style-sheet-media">media</a> must be set to the return value of invoking
<a href="#create-a-medialist-object">create a <code>MediaList</code> object</a> steps for that string.</p>
</dd>
<dt><dfn id="concept-css-style-sheet-title" title="concept-css-style-sheet-title">title</dfn></dt>
<dd>
<p>Specified when created. The title of the <a href="#css-style-sheet">CSS style sheet</a>, which can be the empty string.</p>
<div class="example">
<p>In the following, the <a href="#concept-css-style-sheet-title" title="concept-css-style-sheet-title">title</a> is non-empty
for the first style sheet, but is empty for the second and third style sheets.</p>
<pre>&lt;style title="papaya whip"&gt;
body { background: #ffefd5; }
&lt;/style&gt;</pre>
<pre>&lt;style title=""&gt;
body { background: orange; }
&lt;/style&gt;</pre>
<pre>&lt;style&gt;
body { background: brown; }
&lt;/style&gt;</pre>
</div>
</dd>
<dt><dfn id="concept-css-style-sheet-alternate-flag" title="concept-css-style-sheet-alternate-flag">alternate flag</dfn></dt>
<dd>
<p>Specified when created. Either set or clear. Clear by default.</p>
<div class="example">
<p>The following <a href="#css-style-sheet" title="CSS style sheet">CSS style sheets</a> have
their <a href="#concept-css-style-sheet-alternate-flag" title="concept-css-style-sheet-alternate-flag">alternate flag</a> set:</p>
<pre>&lt;?xml-stylesheet alternate="yes" title="x" href="data:text/css,…"?&gt;</pre>
<pre>&lt;link rel="alternate stylesheet" title="x" href="data:text/css,…"&gt;</pre>
</div>
</dd>
<dt><dfn id="concept-css-style-sheet-disabled-flag" title="concept-css-style-sheet-disabled-flag">disabled flag</dfn></dt>
<dd>
<p>Either set or clear. Clear by default.</p>
<p class="note">Even when clear it does not necessarily mean that the
<a href="#css-style-sheet">CSS style sheet</a> is actually used for rendering.</p>
</dd>
<dt><dfn id="concept-css-style-sheet-css-rules" title="concept-css-style-sheet-css-rules">CSS rules</dfn></dt>
<dd><p>The <a href="#css-rule" title="CSS rule">CSS rules</a> associated with the
<a href="#css-style-sheet">CSS style sheet</a>.</dd>
<dt><dfn id="concept-css-style-sheet-origin-clean-flag" title="concept-css-style-sheet-origin-clean-flag">origin-clean flag</dfn>
<dd><p>Specified when created. Either set or clear. If it is set, the API allows reading and modifying of the <a href="#concept-css-style-sheet-css-rules" title="concept-css-style-sheet-css-rules">CSS
rules</a>.
</dl>
<h4 id="the-stylesheet-interface"><span class="secno">6.1.1 </span>The <code title="">StyleSheet</code> Interface</h4>
<!--
//
// All members defined since DOM-2 Style. Only difference
// is addition of [PutForwards=mediaText], which is presently
// not defined in CSSOM draft.
//
-->
<p>The <code><a href="#stylesheet">StyleSheet</a></code> interface represents an abstract, base style sheet.</p>
<pre class="idl">interface <dfn id="stylesheet">StyleSheet</dfn> {
readonly attribute DOMString <a href="#dom-stylesheet-type" title="dom-StyleSheet-type">type</a>;
readonly attribute DOMString? <a href="#dom-stylesheet-href" title="dom-StyleSheet-href">href</a>;
readonly attribute (<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#element">Element</a> or <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#processinginstruction">ProcessingInstruction</a>)? <!--
--><a href="#dom-stylesheet-ownernode" title="dom-StyleSheet-ownerNode">ownerNode</a>;
readonly attribute <a href="#stylesheet">StyleSheet</a>? <a href="#dom-stylesheet-parentstylesheet" title="dom-StyleSheet-parentStyleSheet">parentStyleSheet</a>;
readonly attribute DOMString? <a href="#dom-stylesheet-title" title="dom-StyleSheet-title">title</a>;
readonly attribute <a href="#medialist">MediaList</a> <a href="#dom-stylesheet-media" title="dom-StyleSheet-media">media</a>;
attribute boolean <a href="#dom-stylesheet-disabled" title="dom-StyleSheet-disabled">disabled</a>;
};</pre>
<p>The <dfn id="dom-stylesheet-type" title="dom-StyleSheet-type"><code>type</code></dfn> attribute must return the <a href="#concept-css-style-sheet-type" title="concept-css-style-sheet-type">type</a>.</p>
5210
<p>The <dfn id="dom-stylesheet-href" title="dom-StyleSheet-href"><code>href</code></dfn> attribute must return the <a href="#concept-css-style-sheet-location" title="concept-css-style-sheet-location">location</a>.</p>
<p>The <dfn id="dom-stylesheet-ownernode" title="dom-StyleSheet-ownerNode"><code>ownerNode</code></dfn> attribute must return the <a href="#concept-css-style-sheet-owner-node" title="concept-css-style-sheet-owner-node">owner
node</a>.</p>
<p>The <dfn id="dom-stylesheet-parentstylesheet" title="dom-StyleSheet-parentStyleSheet"><code>parentStyleSheet</code></dfn> attribute must return the
<a href="#concept-css-style-sheet-parent-css-style-sheet" title="concept-css-style-sheet-parent-css-style-sheet">parent CSS style sheet</a>.</p>
<p>The <dfn id="dom-stylesheet-title" title="dom-StyleSheet-title"><code>title</code></dfn> attribute must return the <a href="#concept-css-style-sheet-title" title="concept-css-style-sheet-title">title</a> or null if
<a href="#concept-css-style-sheet-title" title="concept-css-style-sheet-title">title</a> is the empty string.</p>
<p>The <dfn id="dom-stylesheet-media" title="dom-StyleSheet-media"><code>media</code></dfn> attribute must return the <a href="#concept-css-style-sheet-media" title="concept-css-style-sheet-media">media</a>.</p>
<p>The <dfn id="dom-stylesheet-disabled" title="dom-StyleSheet-disabled"><code>disabled</code></dfn> attribute, on getting, must return true if the
<a href="#concept-css-style-sheet-disabled-flag" title="concept-css-style-sheet-disabled-flag">disabled flag</a>
is set, or false otherwise. On setting, the <code title="dom-StyleSheet-disabled"><a href="#dom-stylesheet-disabled">disabled</a></code> attribute must set the
<a href="#concept-css-style-sheet-disabled-flag" title="concept-css-style-sheet-disabled-flag">disabled flag</a> if the new value is true, or unset the
<a href="#concept-css-style-sheet-disabled-flag" title="concept-css-style-sheet-disabled-flag">disabled flag</a> otherwise.</p>
<h4 id="the-cssstylesheet-interface"><span class="secno">6.1.2 </span>The <code title="">CSSStyleSheet</code> Interface</h4>
<!--
//
// All members defined since DOM-2 Style. The only differences are:
//
// 1. removal of raises(DOMException) on {insert,delete}Rule operations.
//
-->
<p>The <code><a href="#cssstylesheet">CSSStyleSheet</a></code> interface represents a <a href="#css-style-sheet">CSS style sheet</a>.</p>
<pre class="idl">interface <dfn id="cssstylesheet">CSSStyleSheet</dfn> : <a href="#stylesheet">StyleSheet</a> {
readonly attribute <a href="#cssrule">CSSRule</a>? <a href="#dom-cssstylesheet-ownerrule" title="dom-CSSStyleSheet-ownerRule">ownerRule</a>;
readonly attribute <a href="#cssrulelist">CSSRuleList</a> <a href="#dom-cssstylesheet-cssrules" title="dom-CSSStyleSheet-cssRules">cssRules</a>;
unsigned long <a href="#dom-cssstylesheet-insertrule" title="dom-CSSStyleSheet-insertRule">insertRule</a>(DOMString rule, unsigned long index);
void <a href="#dom-cssstylesheet-deleterule" title="dom-CSSStyleSheet-deleteRule">deleteRule</a>(unsigned long index);
};</pre>
<p>The <dfn id="dom-cssstylesheet-ownerrule" title="dom-CSSStyleSheet-ownerRule"><code>ownerRule</code></dfn> attribute must return the <a href="#concept-css-style-sheet-owner-css-rule" title="concept-css-style-sheet-owner-css-rule">owner
CSS rule</a>. If a value other than null is ever returned, then that same value must always be returned on each get access.</p>
<p>The <dfn id="dom-cssstylesheet-cssrules" title="dom-CSSStyleSheet-cssRules"><code>cssRules</code></dfn> attribute must follow these steps:
<ol>
<li><p>If the <a href="#concept-css-style-sheet-origin-clean-flag" title="concept-css-style-sheet-origin-clean-flag">origin-clean flag</a> is clear,
<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> a <code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#securityerror">SecurityError</a></code> exception.
<li><p>Return a read-only, live <code><a href="#cssrulelist">CSSRuleList</a></code> object representing
the <a href="#concept-css-style-sheet-css-rules" title="concept-css-style-sheet-css-rules">CSS rules</a>. The same object must be returned on each get access.</p>
<p class="note">Even though the returned <code><a href="#cssrulelist">CSSRuleList</a></code> object is read-only (from the perspective of
client-authored script), it can nevertheless change over time due to its liveness status. For example, invoking
the <code title="dom-CSSStyleSheet-insertRule"><a href="#dom-cssstylesheet-insertrule">insertRule()</a></code> or <code title="dom-CSSStyleSheet-deleteRule"><a href="#dom-cssstylesheet-deleterule">deleteRule()</a></code> methods can result in
mutations reflected in the returned object.</p>
</ol>
<p>The <dfn id="dom-cssstylesheet-insertrule" title="dom-CSSStyleSheet-insertRule"><code>insertRule(<var>rule</var>, <var>index</var>)</code></dfn> method must run the following steps:
<ol>
<li><p>If the <a href="#concept-css-style-sheet-origin-clean-flag" title="concept-css-style-sheet-origin-clean-flag">origin-clean flag</a> is clear,
<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> a <code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#securityerror">SecurityError</a></code> exception.
<li><p>Return the result of invoking <a href="#insert-a-css-rule">insert a CSS rule</a> <var>rule</var> in the <a href="#concept-css-style-sheet-css-rules" title="concept-css-style-sheet-css-rules">CSS rules</a 3E6E >
at <var>index</var>.
</ol>
<p>The <dfn id="dom-cssstylesheet-deleterule" title="dom-CSSStyleSheet-deleteRule"><code>deleteRule(<var>index</var>)</code></dfn> method must run the following steps:
<ol>
<li><p>If the <a href="#concept-css-style-sheet-origin-clean-flag" title="concept-css-style-sheet-origin-clean-flag">origin-clean flag</a> is clear,
<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> a <code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#securityerror">SecurityError</a></code> exception.
<li><p><a href="#remove-a-css-rule">Remove a CSS rule</a> in the <a href="#concept-css-style-sheet-css-rules" title="concept-css-style-sheet-css-rules">CSS rules</a> at <var>index</var>.
</ol>
<h3 id="css-style-sheet-collections"><span class="secno">6.2 </span>CSS Style Sheet Collections</h3>