Skip to content

Commit 174e3e8

Browse files
committed
[css-syntax] Further clarify the '@charset does nothing' text.
1 parent 490a590 commit 174e3e8

2 files changed

Lines changed: 47 additions & 23 deletions

File tree

css-syntax/Overview.html

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</p>
5555
<h1 class="p-name no-ref" id=title>CSS Syntax Module Level 3</h1>
5656
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
57-
<span class=dt-updated><span class=value-title title=20140108>8 January 2014</span></span></span></h2>
57+
<span class=dt-updated><span class=value-title title=20140115>15 January 2014</span></span></span></h2>
5858
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-syntax/>http://dev.w3.org/csswg/css-syntax/</a><dt>Latest version:<dd><a href=http://www.w3.org/TR/css-syntax-3/>http://www.w3.org/TR/css-syntax-3/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-syntax/>http://dev.w3.org/csswg/css-syntax/</a><dt>Previous Versions:<dd><a href=http://www.w3.org/TR/2013/WD-css-syntax-3-20131105/ rel=previous>http://www.w3.org/TR/2013/WD-css-syntax-3-20131105/</a><dd><a href=http://www.w3.org/TR/2013/WD-css-syntax-3-20130919/ rel=previous>http://www.w3.org/TR/2013/WD-css-syntax-3-20130919/</a>
5959
<dt>Feedback:</dt>
6060
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-syntax%5D%20feedback">www-style@w3.org</a>
@@ -4499,17 +4499,29 @@ <h3 class="heading settled heading" data-level=8.2 id=charset-rule><span class=s
44994499
<p> The <a class=css data-link-type=maybe href=#at-ruledef-charset title=@charset>@charset</a> rule has <strong>no effect on a stylesheet</strong>.
45004500

45014501
<div class=note>
4502-
Note: This only applies to the <a data-link-type=dfn href=#at-rule title=at-rule>at-rule</a>
4503-
created by the algorithm to <a data-link-type=dfn href=#parse-a-stylesheet0 title="parse a stylesheet">parse a stylesheet</a>,
4504-
not to the ASCII <code>@charset "XXX";</code> byte sequence
4505-
that the algorithm to <a data-link-type=dfn href=#determine-the-fallback-encoding title="determine the fallback encoding">determine the fallback encoding</a>
4506-
looks for at the beginning of a stylesheet.
4507-
4508-
<p> While they look similar, they are not actually the same thing.
4509-
For example, a slightly different byte sequence
4510-
(more whitespace, single instead of double quotes, …)
4511-
will not be considered for the fallback encoding
4512-
but may still generate an <a class=css data-link-type=maybe href=#at-ruledef-charset title=@charset>@charset</a> rule that shows up in <a data-biblio-type=informative data-link-type=biblio href=#cssom title=cssom>[CSSOM]</a>.
4502+
Confused?
4503+
Note that the preceding paragraph is talking about the <a class=css data-link-type=maybe href=#at-ruledef-charset title=@charset>@charset</a> <strong><a data-link-type=dfn href=#at-rule title=at-rule>at-rule</a></strong>.
4504+
CSS looks for a byte sequence that looks like "@charset" at the beginning of the document
4505+
to receive encoding enformation.
4506+
This is thematically similar to other encoding sequences at the beginning of files,
4507+
like a byte-order mark (BOM) hinting at the type of Unicode encoding used,
4508+
a DOCTYPE in an HTML document,
4509+
or a magic string like "MANIFEST" at the start of an HTML manifest.
4510+
4511+
<p> This byte sequence happens to <em>look</em> like a normal CSS rule, however,
4512+
and for legacy reasons,
4513+
that rule is reflected as an <a data-link-type=dfn href=#at-rule title=at-rule>at-rule</a> in the CSS Object Model <a data-biblio-type=informative data-link-type=biblio href=#cssom title=cssom>[CSSOM]</a>.
4514+
However, <strong>that at-rule object does nothing</strong>;
4515+
modifying it has no effect on the stylesheet,
4516+
nor does creating a fresh one and inserting it into a stylesheet.
4517+
4518+
<p> Note that some syntax that qualifies as a valid <a class=css data-link-type=maybe href=#at-ruledef-charset title=@charset>@charset</a> <a data-link-type=dfn href=#at-rule title=at-rule>at-rule</a>
4519+
is <strong>not</strong> a valid encoding declaration.
4520+
For example, since its argument is a string,
4521+
it can be written with single quotes around it.
4522+
This will create a valid <a class=css data-link-type=maybe href=#at-ruledef-charset title=@charset>@charset</a> rule,
4523+
but it won’t be recognized by the encoding detection step,
4524+
as it’s not the exact byte sequence that the algorithm requires.
45134525
</div>
45144526

45154527

css-syntax/Overview.src.html

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3025,17 +3025,29 @@ <h3 id='charset-rule'>
30253025
The ''@charset'' rule has <strong>no effect on a stylesheet</strong>.
30263026

30273027
<div class='note'>
3028-
Note: This only applies to the <a>at-rule</a>
3029-
created by the algorithm to <a>parse a stylesheet</a>,
3030-
not to the ASCII <code>@charset "XXX";</code> byte sequence
3031-
that the algorithm to <a>determine the fallback encoding</a>
3032-
looks for at the beginning of a stylesheet.
3033-
3034-
While they look similar, they are not actually the same thing.
3035-
For example, a slightly different byte sequence
3036-
(more whitespace, single instead of double quotes, …)
3037-
will not be considered for the fallback encoding
3038-
but may still generate an ''@charset'' rule that shows up in [[CSSOM]].
3028+
Confused?
3029+
Note that the preceding paragraph is talking about the ''@charset'' <strong><a>at-rule</a></strong>.
3030+
CSS looks for a byte sequence that looks like "@charset" at the beginning of the document
3031+
to receive encoding enformation.
3032+
This is thematically similar to other encoding sequences at the beginning of files,
3033+
like a byte-order mark (BOM) hinting at the type of Unicode encoding used,
3034+
a DOCTYPE in an HTML document,
3035+
or a magic string like "MANIFEST" at the start of an HTML manifest.
3036+
3037+
This byte sequence happens to <em>look</em> like a normal CSS rule, however,
3038+
and for legacy reasons,
3039+
that rule is reflected as an <a>at-rule</a> in the CSS Object Model [[CSSOM]].
3040+
However, <strong>that at-rule object does nothing</strong>;
3041+
modifying it has no effect on the stylesheet,
3042+
nor does creating a fresh one and inserting it into a stylesheet.
3043+
3044+
Note that some syntax that qualifies as a valid ''@charset'' <a>at-rule</a>
3045+
is <strong>not</strong> a valid encoding declaration.
3046+
For example, since its argument is a string,
3047+
it can be written with single quotes around it.
3048+
This will create a valid ''@charset'' rule,
3049+
but it won't be recognized by the encoding detection step,
3050+
as it's not the exact byte sequence that the algorithm requires.
30393051
</div>
30403052

30413053

0 commit comments

Comments
 (0)