[css-syntax] Initial draft of the CSS Stylesheets section.

Tue, 23 Jul 2013 15:04:44 +0100

author
Simon Sapin <simon.sapin@exyr.org>
date
Tue, 23 Jul 2013 15:04:44 +0100
changeset 8741
0ea487450d92
parent 8740
18aec6520bfb
child 8742
1fe4493083f9

[css-syntax] Initial draft of the CSS Stylesheets section.

css-syntax/Overview.html file | annotate | diff | comparison | revisions
css-syntax/Overview.src.html file | annotate | diff | comparison | revisions
     1.1 --- a/css-syntax/Overview.html	Tue Jul 23 11:34:50 2013 +0100
     1.2 +++ b/css-syntax/Overview.html	Tue Jul 23 15:04:44 2013 +0100
     1.3 @@ -115,8 +115,8 @@
     1.4  Informal Syntax Description</a><li><a href=#the-anb-type><span class=secno>6.2</span>
     1.5  The <code>&lt;an+b&gt;</code> type</a></ul><li><a href=#rule-defs><span class=secno>7</span>
     1.6  Defining Grammars for Rules and Other Values</a><ul class=toc><li><a href=#declaration-rule-list><span class=secno>7.1</span>
     1.7 -Defining Block Contents: the <var>&lt;declaration-list&gt;</var>, <var>&lt;rule-list&gt;</var>, and <var>&lt;stylesheet&gt;</var> productions</a></ul><li><a href=#serialization><span class=secno>8</span>Serialization</a><ul class=toc><li><a href=#serializing-anb><span class=secno>8.1</span>
     1.8 -Serializing <var>&lt;an+b&gt;</var></a></ul><li><a href=#changes><span class=secno>9</span>Changes from CSS 2.1 and Selectors Level 3</a><li><a href=#acknowledgments><span class=secno></span>
     1.9 +Defining Block Contents: the <var>&lt;declaration-list&gt;</var>, <var>&lt;rule-list&gt;</var>, and <var>&lt;stylesheet&gt;</var> productions</a></ul><li><a href=#css-stylesheets><span class=secno>8</span>CSS stylesheets</a><ul class=toc><li><a href=#style-rules><span class=secno>8.1</span>Style rules</a><li><a href=#charset-rules><span class=secno>8.2</span><span class=css data-autolink=maybe>@charset</span> rules</a><li><a href=#other-at-rules-rules><span class=secno>8.3</span>Other at-rules rules</a></ul><li><a href=#serialization><span class=secno>9</span>Serialization</a><ul class=toc><li><a href=#serializing-anb><span class=secno>9.1</span>
    1.10 +Serializing <var>&lt;an+b&gt;</var></a></ul><li><a href=#changes><span class=secno>10</span>Changes from CSS 2.1 and Selectors Level 3</a><li><a href=#acknowledgments><span class=secno></span>
    1.11  Acknowledgments</a><li><a href=#conformance><span class=secno></span>
    1.12  Conformance</a><ul class=toc><li><a href=#conventions><span class=secno></span>
    1.13  Document conventions</a><li><a href=#conformance-classes><span class=secno></span>
    1.14 @@ -2688,9 +2688,108 @@
    1.15  	</div>
    1.16  
    1.17  
    1.18 -
    1.19 -
    1.20 -<h2 data-level=8 id=serialization><span class=secno>8 </span><span class=content>Serialization</span><a class=section-link href=#serialization>§</a></h2>
    1.21 +<h2 data-level=8 id=css-stylesheets><span class=secno>8 </span><span class=content>CSS stylesheets</span><a class=section-link href=#css-stylesheets>§</a></h2>
    1.22 +
    1.23 +<p>	A CSS stylesheet is parsed with <a href=#parse-a-stylesheet0>Parse a stylesheet</a>,
    1.24 +	interpreting the resulting <a href=#qualified-rule>qualified rules</a> and <a href=#at-rule>at-rules</a> as follows.
    1.25 +	Each of these is either transformed into a <a href=#style-rules0>style rule</a> or another type of rule,
    1.26 +	or is found invalid. Invalid rules are ignored with a <a href=#parse-errors>parse errors</a>.
    1.27 +
    1.28 +
    1.29 +<h3 data-level=8.1 id=style-rules><span class=secno>8.1 </span><span class=content>Style rules</span><a class=section-link href=#style-rules>§</a></h3>
    1.30 +
    1.31 +	<p>
    1.32 +		<dfn data-dfn-type=link id=style-rules0 title="style rule|style rules">Style rules</dfn> are <a href=#qualified-rule>qualified rules</a>
    1.33 +		that associate a <a href=http://dev.w3.org/csswg/selectors4/#selector-list>selector list</a> <a data-autolink=biblio data-biblio-type=normative href=#select title=SELECT>[SELECT]</a>
    1.34 +		with a list of property declarations.
    1.35 +		They are also called
    1.36 +		<a href=http://www.w3.org/TR/CSS21/syndata.html#rule-sets>rule sets</a> in <a data-autolink=biblio data-biblio-type=normative href=#css21 title=CSS21>[CSS21]</a>.
    1.37 +		CSS Cascading and Inheritance <a data-autolink=biblio data-biblio-type=normative href=#css3cascade title=CSS3CASCADE>[CSS3CASCADE]</a> defines how style rules participate in the cascade.
    1.38 +
    1.39 +	<p>
    1.40 +		The prelude of the qualified rule is parsed as a
    1.41 +		<a href=http://dev.w3.org/csswg/selectors4/#selector-list>selector list</a>.
    1.42 +		A style rule with an invalid selector is invalid: the whole rule is ignored.
    1.43 +
    1.44 +	<p>
    1.45 +		The content of the qualified rule’s block is parsed as a
    1.46 +		<a href=#parse-a-list-of-declarations0 title="parse a list of declarations">list of declarations</a>.
    1.47 +		Unless defined otherwise by another specification or a future level of this specification,
    1.48 +		at-rules in that list are invalid.
    1.49 +		Declaration for an unknown CSS property
    1.50 +		or whose value does not match the syntax defined by the property are invalid.
    1.51 +		Invalid declarations or at-rules are ignored with a <a href=#parse-errors>parse error</a>,
    1.52 +		they do not make the rule invalid.
    1.53 +		Unless otherwise specified, property names are <a href=#ascii-case-insensitive>ASCII case-insensitive</a>.
    1.54 +
    1.55 +	<p class=note>
    1.56 +		The name of Custom Properties <a data-autolink=biblio data-biblio-type=informative href=#css-variables title=CSS-VARIABLES>[CSS-VARIABLES]</a> is case-sensitive.
    1.57 +
    1.58 +	<p>
    1.59 +		<a href=#qualified-rule>Qualified rules</a> at the top-level of a CSS stylesheet are style rules.
    1.60 +		Qualified rules in other contexts may or may not be style rules,
    1.61 +		as defined by the context.
    1.62 +
    1.63 +	<p class=note>
    1.64 +		For example qualified rules inside <span class=css data-autolink=maybe>@media</span> rules <a data-autolink=biblio data-biblio-type=informative href=#css3-conditional title=CSS3-CONDITIONAL>[CSS3-CONDITIONAL]</a> are style rules,
    1.65 +		but not they’re not inside <span class=css data-autolink=maybe>@keyframes</span> rules <a data-autolink=biblio data-biblio-type=informative href=#css3-animations title=CSS3-ANIMATIONS>[CSS3-ANIMATIONS]</a>.
    1.66 +
    1.67 +
    1.68 +<h3 data-level=8.2 id=charset-rules><span class=secno>8.2 </span><span class=content><span class=css data-autolink=maybe>@charset</span> rules</span><a class=section-link href=#charset-rules>§</a></h3>
    1.69 +
    1.70 +	<p>
    1.71 +		<dfn data-dfn-type=at-rule id=charset-rules0><span class=css data-autolink=maybe>@charset</span> rules</dfn> are <a href=#at-rule>at-rules</a> whose name is an <a href=#ascii-case-insensitive>ASCII case-insensitive</a> match for "charset".
    1.72 +
    1.73 +	<p>
    1.74 +		An <span class=css data-autolink=maybe>@charset</span> rule is invalid if it is not at the top-level of a stylesheet,
    1.75 +		if it is not the very first rule of a stylesheet,
    1.76 +		or if does not match the following <a href=#rule-defs>grammar</a>:
    1.77 +
    1.78 +<pre>&lt;at-charset-rule&gt; = @charset 〈string〉;</pre>
    1.79 +	<p>
    1.80 +		<span class=css data-autolink=maybe>@charset</span> rules have an <dfn data-dfn-type=link id=at-charset-encoding>encoding</dfn>,
    1.81 +		given by the value of the 〈string〉 token.
    1.82 +
    1.83 +	<div class=issue>
    1.84 +		<p>
    1.85 +			Although I don’t think it make sense,
    1.86 +			current implementations seem to consider "valid" (and reflect in <a data-autolink=biblio data-biblio-type=informative href=#cssom title=CSSOM>[CSSOM]</a>)
    1.87 +			<span class=css data-autolink=maybe>@charset</span> rules that:
    1.88 +
    1.89 +<p>		<ul>
    1.90 +			<li>
    1.91 +				Don’t match the byte pattern that
    1.92 +				<a href=#the-input-byte-stream>The input byte stream</a> looks for,
    1.93 +			<li>
    1.94 +				or contain an invalid encoding name,
    1.95 +			<li>
    1.96 +				or are in a stylesheet that was not decoded from bytes.
    1.97 +				(e.g. HTML <code>style</code> element.)
    1.98 +		</ul>
    1.99 +	</div>
   1.100 +
   1.101 +	<p class=note>
   1.102 +		<span class=css data-autolink=maybe>@charset</span> rules may help
   1.103 +		<a href=#the-input-byte-stream>determine the character encoding</a>
   1.104 +		of a stylesheet parse from bytes,
   1.105 +		but they don’t have any other effect.
   1.106 +
   1.107 +<h3 data-level=8.3 id=other-at-rules-rules><span class=secno>8.3 </span><span class=content>Other at-rules rules</span><a class=section-link href=#other-at-rules-rules>§</a></h3>
   1.108 +
   1.109 +	<p>
   1.110 +		Other specifications may define specific types of at-rules based on their name.
   1.111 +		Such definitions must include what contexts a given type of at-rule is valid in.
   1.112 +		At-rules of unknown type are invalid.
   1.113 +
   1.114 +	<p class=example>
   1.115 +		<span class=css data-autolink=maybe>@import</span> rules <a data-autolink=biblio data-biblio-type=informative href=#css3cascade title=CSS3CASCADE>[CSS3CASCADE]</a> must be at the top-level of a stylesheet,
   1.116 +		after <span class=css data-autolink=maybe>@charset</span> rules, and before any other rules.
   1.117 +
   1.118 +	<p class=example>
   1.119 +		Margin rules <a data-autolink=biblio data-biblio-type=informative href=#css3page title=CSS3PAGE>[CSS3PAGE]</a> must be directly inside a <span class=css data-autolink=maybe>@page</span> rule.
   1.120 +
   1.121 +
   1.122 +<h2 data-level=9 id=serialization><span class=secno>9 </span><span class=content>Serialization</span><a class=section-link href=#serialization>§</a></h2>
   1.123  
   1.124  <p>	This specification does not define how to serialize CSS in general,
   1.125  	leaving that task to the CSSOM and individual feature specifications.
   1.126 @@ -2737,7 +2836,7 @@
   1.127  	so the above rule reinserts the minimum number of comments into the serialized text to ensure an accurate round-trip.
   1.128  	(Roughly.  The 〈delim〉 rules are slightly too powerful, for simplicity.)
   1.129  
   1.130 -<h3 data-level=8.1 id=serializing-anb><span class=secno>8.1 </span><span class=content>
   1.131 +<h3 data-level=9.1 id=serializing-anb><span class=secno>9.1 </span><span class=content>
   1.132  Serializing <var>&lt;an+b&gt;</var></span><a class=section-link href=#serializing-anb>§</a></h3>
   1.133  
   1.134  <p>	To serialize an <var>&lt;an+b&gt;</var> value,
   1.135 @@ -2768,7 +2867,7 @@
   1.136  
   1.137  <p>		Return <var>s</var>.
   1.138  
   1.139 -<h2 data-level=9 id=changes><span class=secno>9 </span><span class=content>Changes from CSS 2.1 and Selectors Level 3</span><a class=section-link href=#changes>§</a></h2>
   1.140 +<h2 data-level=10 id=changes><span class=secno>10 </span><span class=content>Changes from CSS 2.1 and Selectors Level 3</span><a class=section-link href=#changes>§</a></h2>
   1.141  
   1.142  <p>	<em>This section is non-normative.</em>
   1.143  
   1.144 @@ -3047,11 +3146,11 @@
   1.145  
   1.146  <h3 class="no-num no-ref" id=normative><span class=content>
   1.147  Normative References</span><a class=section-link href=#normative>§</a></h3>
   1.148 -<div data-fill-with=normative-references><dl><dt id=rfc2119 title=RFC2119>[RFC2119]<dd>S. Bradner. <a href=http://www.ietf.org/rfc/rfc2119.txt>Key words for use in RFCs to Indicate Requirement Levels</a>. URL: <a href=http://www.ietf.org/rfc/rfc2119.txt>http://www.ietf.org/rfc/rfc2119.txt</a></dl></div>
   1.149 +<div data-fill-with=normative-references><dl><dt id=css21 title=CSS21>[CSS21]<dd>Bert Bos; et al. <a href=http://www.w3.org/TR/2011/REC-CSS2-20110607/>Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification</a>. 7 June 2011. W3C Recommendation. URL: <a href=http://www.w3.org/TR/2011/REC-CSS2-20110607/>http://www.w3.org/TR/2011/REC-CSS2-20110607/</a><dt id=css3cascade title=CSS3CASCADE>[CSS3CASCADE]<dd>Håkon Wium Lie; Elika J. Etemad; Tab Atkins Jr.. <a href=http://www.w3.org/TR/2013/WD-css3-cascade-20130103/>CSS Cascading and Inheritance Level 3</a>. 3 January 2013. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2013/WD-css3-cascade-20130103/>http://www.w3.org/TR/2013/WD-css3-cascade-20130103/</a><dt id=rfc2119 title=RFC2119>[RFC2119]<dd>S. Bradner. <a href=http://www.ietf.org/rfc/rfc2119.txt>Key words for use in RFCs to Indicate Requirement Levels</a>. URL: <a href=http://www.ietf.org/rfc/rfc2119.txt>http://www.ietf.org/rfc/rfc2119.txt</a><dt id=select title=SELECT>[SELECT]<dd>Tantek Çelik; et al. <a href=http://www.w3.org/TR/2011/REC-css3-selectors-20110929/>Selectors Level 3</a>. 29 September 2011. W3C Recommendation. URL: <a href=http://www.w3.org/TR/2011/REC-css3-selectors-20110929/>http://www.w3.org/TR/2011/REC-css3-selectors-20110929/</a></dl></div>
   1.150  
   1.151  <h3 class="no-num no-ref" id=informative><span class=content>
   1.152  Informative References</span><a class=section-link href=#informative>§</a></h3>
   1.153 -<div data-fill-with=informative-references><dl><dt id=css3-conditional title=CSS3-CONDITIONAL>[CSS3-CONDITIONAL]<dd>L. David Baron. <a href=http://www.w3.org/TR/2012/WD-css3-conditional-20121213/>CSS Conditional Rules Module Level 3</a>. 13 December 2012. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2012/WD-css3-conditional-20121213/>http://www.w3.org/TR/2012/WD-css3-conditional-20121213/</a><dt id=mediaq title=MEDIAQ>[MEDIAQ]<dd>Florian Rivoal. <a href=http://www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/>Media Queries</a>. 19 June 2012. W3C Recommendation. URL: <a href=http://www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/>http://www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/</a><dt id=select title=SELECT>[SELECT]<dd>Tantek Çelik; et al. <a href=http://www.w3.org/TR/2011/REC-css3-selectors-20110929/>Selectors Level 3</a>. 29 September 2011. W3C Recommendation. URL: <a href=http://www.w3.org/TR/2011/REC-css3-selectors-20110929/>http://www.w3.org/TR/2011/REC-css3-selectors-20110929/</a></dl></div>
   1.154 +<div data-fill-with=informative-references><dl><dt id=css-variables title=CSS-VARIABLES>[CSS-VARIABLES]<dd>Luke Macpherson; Tab Atkins Jr.; Daniel Glazman. <a href=http://www.w3.org/TR/2012/WD-css-variables-20120410/>CSS Variables Module Level 1</a>. 10 April 2012. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2012/WD-css-variables-20120410/>http://www.w3.org/TR/2012/WD-css-variables-20120410/</a><dt id=css3-animations title=CSS3-ANIMATIONS>[CSS3-ANIMATIONS]<dd>Dean Jackson; et al. <a href=http://www.w3.org/TR/2012/WD-css3-animations-20120403/>CSS Animations</a>. 3 April 2012. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2012/WD-css3-animations-20120403/>http://www.w3.org/TR/2012/WD-css3-animations-20120403/</a><dt id=css3-conditional title=CSS3-CONDITIONAL>[CSS3-CONDITIONAL]<dd>L. David Baron. <a href=http://www.w3.org/TR/2012/WD-css3-conditional-20121213/>CSS Conditional Rules Module Level 3</a>. 13 December 2012. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2012/WD-css3-conditional-20121213/>http://www.w3.org/TR/2012/WD-css3-conditional-20121213/</a><dt id=css3page title=CSS3PAGE>[CSS3PAGE]<dd>Håkon Wium Lie; Melinda Grant. <a href=http://www.w3.org/TR/2006/WD-css3-page-20061010>CSS3 Module: Paged Media</a>. 10 October 2006. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2006/WD-css3-page-20061010>http://www.w3.org/TR/2006/WD-css3-page-20061010</a><dt id=cssom title=CSSOM>[CSSOM]<dd>Anne van Kesteren. <a href=http://www.w3.org/TR/2011/WD-cssom-20110712/>CSSOM</a>. 12 July 2011. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2011/WD-cssom-20110712/>http://www.w3.org/TR/2011/WD-cssom-20110712/</a><dt id=mediaq title=MEDIAQ>[MEDIAQ]<dd>Florian Rivoal. <a href=http://www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/>Media Queries</a>. 19 June 2012. W3C Recommendation. URL: <a href=http://www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/>http://www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/</a></dl></div>
   1.155  
   1.156  <h2 class="no-num no-ref" id=index><span class=content>
   1.157  Index</span><a class=section-link href=#index>§</a></h2>
   1.158 @@ -3063,6 +3162,7 @@
   1.159  <li>ASCII case-insensitive, <a href=#ascii-case-insensitive title="section 5.2">5.2</a>
   1.160  <li>at-rule, <a href=#at-rule title="section 5">5</a>
   1.161  <li>B, <a href=#b title="section 6">6</a>
   1.162 +<li>@charset rules, <a href=#charset-rules0 title="section 8.2">8.2</a>
   1.163  <li>check if three characters would start an identifier, <a href=#check-if-three-characters-would-start-an-identifier0 title="section 4.3.9">4.3.9</a>
   1.164  <li>check if three characters would start a number, <a href=#check-if-three-characters-would-start-a-number0 title="section 4.3.10">4.3.10</a>
   1.165  <li>check if two characters are a valid escape, <a href=#check-if-two-characters-are-a-valid-escape0 title="section 4.3.8">4.3.8</a>
   1.166 @@ -3094,6 +3194,7 @@
   1.167  <li>&lt;declaration-list&gt;, <a href=#declaration-list title="section 7.1">7.1</a>
   1.168  <li>decode, <a href=#decode title="section 3.2">3.2</a>
   1.169  <li>digit, <a href=#digit title="section 4.2">4.2</a>
   1.170 +<li>encoding, <a href=#at-charset-encoding title="section 8.2">8.2</a>
   1.171  <li>ending token, <a href=#ending-token title="section 5.4.7">5.4.7</a>
   1.172  <li>end of the range, <a href=#end-of-the-range title="section 4.3.15">4.3.15</a>
   1.173  <li>〈EOF〉, <a href=#eof title="section 5.2">5.2</a>
   1.174 @@ -3138,6 +3239,8 @@
   1.175  <li>starts with a valid escape, <a href=#check-if-two-characters-are-a-valid-escape0 title="section 4.3.8">4.3.8</a>
   1.176  <li>start with an identifier, <a href=#check-if-three-characters-would-start-an-identifier0 title="section 4.3.9">4.3.9</a>
   1.177  <li>start with a number, <a href=#check-if-three-characters-would-start-a-number0 title="section 4.3.10">4.3.10</a>
   1.178 +<li>style rule, <a href=#style-rules0 title="section 8.1">8.1</a>
   1.179 +<li>style rules, <a href=#style-rules0 title="section 8.1">8.1</a>
   1.180  <li>&lt;stylesheet&gt;, <a href=#stylesheet title="section 7.1">7.1</a>
   1.181  <li>top-level flag, <a href=#top-level-flag title="section 5.4.1">5.4.1</a>
   1.182  <li>uppercase letter, <a href=#uppercase-letter title="section 4.2">4.2</a>
     2.1 --- a/css-syntax/Overview.src.html	Tue Jul 23 11:34:50 2013 +0100
     2.2 +++ b/css-syntax/Overview.src.html	Tue Jul 23 15:04:44 2013 +0100
     2.3 @@ -2579,6 +2579,106 @@
     2.4  	</div>
     2.5  
     2.6  
     2.7 +<h2>CSS stylesheets</h2>
     2.8 +
     2.9 +	A CSS stylesheet is parsed with <i>Parse a stylesheet</i>,
    2.10 +	interpreting the resulting <i>qualified rules</i> and <i>at-rules</i> as follows.
    2.11 +	Each of these is either transformed into a <i>style rule</i> or another type of rule,
    2.12 +	or is found invalid. Invalid rules are ignored with a <i>parse errors</i>.
    2.13 +
    2.14 +
    2.15 +<h3>Style rules</h3>
    2.16 +
    2.17 +	<p>
    2.18 +		<dfn title="style rule|style rules">Style rules</dfn> are <i>qualified rules</i>
    2.19 +		that associate a <a href="http://dev.w3.org/csswg/selectors4/#selector-list">selector list</a> [[!SELECT]]
    2.20 +		with a list of property declarations.
    2.21 +		They are also called
    2.22 +		<a href="http://www.w3.org/TR/CSS21/syndata.html#rule-sets">rule sets</a> in [[!CSS21]].
    2.23 +		CSS Cascading and Inheritance [[!CSS3CASCADE]] defines how style rules participate in the cascade.
    2.24 +
    2.25 +	<p>
    2.26 +		The prelude of the qualified rule is parsed as a
    2.27 +		<a href="http://dev.w3.org/csswg/selectors4/#selector-list">selector list</a>.
    2.28 +		A style rule with an invalid selector is invalid: the whole rule is ignored.
    2.29 +
    2.30 +	<p>
    2.31 +		The content of the qualified rule’s block is parsed as a
    2.32 +		<i title="parse a list of declarations">list of declarations</i>.
    2.33 +		Unless defined otherwise by another specification or a future level of this specification,
    2.34 +		at-rules in that list are invalid.
    2.35 +		Declaration for an unknown CSS property
    2.36 +		or whose value does not match the syntax defined by the property are invalid.
    2.37 +		Invalid declarations or at-rules are ignored with a <i>parse error</i>,
    2.38 +		they do not make the rule invalid.
    2.39 +		Unless otherwise specified, property names are <i>ASCII case-insensitive</i>.
    2.40 +
    2.41 +	<p class=note>
    2.42 +		The name of Custom Properties [[CSS-VARIABLES]] is case-sensitive.
    2.43 +
    2.44 +	<p>
    2.45 +		<i>Qualified rules</i> at the top-level of a CSS stylesheet are style rules.
    2.46 +		Qualified rules in other contexts may or may not be style rules,
    2.47 +		as defined by the context.
    2.48 +
    2.49 +	<p class=note>
    2.50 +		For example qualified rules inside ''@media'' rules [[CSS3-CONDITIONAL]] are style rules,
    2.51 +		but not they’re not inside ''@keyframes'' rules [[CSS3-ANIMATIONS]].
    2.52 +
    2.53 +
    2.54 +<h3>''@charset'' rules</h3>
    2.55 +
    2.56 +	<p>
    2.57 +		<dfn>''@charset'' rules</dfn> are <i>at-rules</i> whose name is an <i>ASCII case-insensitive</i> match for "charset".
    2.58 +
    2.59 +	<p>
    2.60 +		An ''@charset'' rule is invalid if it is not at the top-level of a stylesheet,
    2.61 +		if it is not the very first rule of a stylesheet,
    2.62 +		or if does not match the following <a href="#rule-defs">grammar</a>:
    2.63 +
    2.64 +	<pre>&lt;at-charset-rule> = @charset 〈string〉;</pre>
    2.65 +
    2.66 +	<p>
    2.67 +		''@charset'' rules have an <dfn id=at-charset-encoding>encoding</dfn>,
    2.68 +		given by the value of the 〈string〉 token.
    2.69 +
    2.70 +	<div class=issue>
    2.71 +		<p>
    2.72 +			Although I don’t think it make sense,
    2.73 +			current implementations seem to consider "valid" (and reflect in [[CSSOM]])
    2.74 +			''@charset'' rules that:
    2.75 +
    2.76 +		<ul>
    2.77 +			<li>
    2.78 +				Don’t match the byte pattern that
    2.79 +				<a href="#the-input-byte-stream">The input byte stream</a> looks for,
    2.80 +			<li>
    2.81 +				or contain an invalid encoding name,
    2.82 +			<li>
    2.83 +				or are in a stylesheet that was not decoded from bytes.
    2.84 +				(e.g. HTML <code>style</code> element.)
    2.85 +		</ul>
    2.86 +	</div>
    2.87 +
    2.88 +	<p class=note>
    2.89 +		''@charset'' rules may help
    2.90 +		<a href="#the-input-byte-stream">determine the character encoding</a>
    2.91 +		of a stylesheet parse from bytes,
    2.92 +		but they don’t have any other effect.
    2.93 +
    2.94 +<h3>Other at-rules rules</h3>
    2.95 +
    2.96 +	<p>
    2.97 +		Other specifications may define specific types of at-rules based on their name.
    2.98 +		Such definitions must include what contexts a given type of at-rule is valid in.
    2.99 +		At-rules of unknown type are invalid.
   2.100 +
   2.101 +	<p class=example>
   2.102 +		''@import'' rules [[CSS3CASCADE]] must be at the top-level of a stylesheet,
   2.103 +		after ''@charset'' rules, and before any other rules.
   2.104 +
   2.105 +	<p class=example>
   2.106 +		Margin rules [[CSS3PAGE]] must be directly inside a ''@page'' rule.
   2.107  
   2.108  
   2.109  <h2>Serialization</h2>

mercurial