You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but qualified rules inside <spanclass=cssdata-link-type=maybetitle=@keyframes>@keyframes</span> rules are not <adata-biblio-type=informativedata-link-type=bibliohref=#css3-animationstitle=css3-animations>[CSS3-ANIMATIONS]</a>.
The <aclass=cssdata-link-type=maybehref=#at-ruledef-charsettitle=@charset>@charset</a> Rule</span><aclass=self-linkhref=#charset-rule></a></h3>
4487
+
The <spanclass=cssdata-link-type=maybetitle=@charset>@charset</span> Rule</span><aclass=self-linkhref=#charset-rule></a></h3>
4488
4488
4489
-
<p> The <dfnclass=css-codedata-dfn-type=at-ruledata-export="" id=at-ruledef-charset>@charset<aclass=self-linkhref=#at-ruledef-charset></a></dfn> rule is a very special <adata-link-type=dfnhref=#at-ruletitle=at-rule>at-rule</a> associated with determining the character encoding of the stylesheet.
4490
-
In general, its grammar is:
4489
+
<p> The @charset rule is an artifact of the algorithm used to <adata-link-type=dfnhref=#determine-the-fallback-encodingtitle="determine the fallback encoding">determine the fallback encoding</a> for the stylesheet.
4490
+
That algorithm looks for a specific byte sequence as the very first few bytes in the file,
4491
+
which has the syntactic form of an @-rule.
4492
+
Those bytes are not discarded from the input,
4493
+
whether or not they influence the encoding actually used to process the stylesheet.
<p> Additionally, an <aclass=cssdata-link-type=maybehref=#at-ruledef-charsettitle=@charset>@charset</a> rule is invalid if it is not at the top-level of a stylesheet,
4494
-
or if it is not the very first rule of a stylesheet.
4495
+
<p> Therefore, the stylesheet parser recognizes an @-rule with the general syntax
4495
4496
4496
-
<p><aclass=cssdata-link-type=maybehref=#at-ruledef-charsettitle=@charset>@charset</a> rules have an <dfndata-dfn-type=dfndata-noexport="" id=at-charset-encoding>encoding<aclass=self-linkhref=#at-charset-encoding></a></dfn>,
4497
-
given by the value of the <aclass="production css-code" data-link-type=typehref=http://dev.w3.org/csswg/css-values-3/#string-valuetitle="<string>"><string></a>.
4498
-
4499
-
<p> The <aclass=cssdata-link-type=maybehref=#at-ruledef-charsettitle=@charset>@charset</a> rule has <strong>no effect on a stylesheet</strong>.
4500
-
4501
-
<divclass=note>
4502
-
Confused?
4503
-
Note that the preceding paragraph is talking about the <aclass=cssdata-link-type=maybehref=#at-ruledef-charsettitle=@charset>@charset</a><strong><adata-link-type=dfnhref=#at-ruletitle=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 <adata-link-type=dfnhref=#at-ruletitle=at-rule>at-rule</a> in the CSS Object Model <adata-biblio-type=informativedata-link-type=bibliohref=#cssomtitle=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 <aclass=cssdata-link-type=maybehref=#at-ruledef-charsettitle=@charset>@charset</a><adata-link-type=dfnhref=#at-ruletitle=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 <aclass=cssdata-link-type=maybehref=#at-ruledef-charsettitle=@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.
0 commit comments