This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 28533 - Authoring conformance for @charset
Summary: Authoring conformance for @charset
Status: NEW
Alias: None
Product: CSS
Classification: Unclassified
Component: Syntax (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Tab Atkins Jr.
QA Contact: public-css-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-22 08:11 UTC by Simon Pieters
Modified: 2015-05-06 17:54 UTC (History)
0 users

See Also:


Attachments

Description Simon Pieters 2015-04-22 08:11:52 UTC
The current state of css-syntax is a bit unclear when it comes to authoring conformance for @charset.

http://dev.w3.org/csswg/css-syntax/#input-byte-stream does not say anything is a parse error/syntax error.

http://dev.w3.org/csswg/css-syntax/#parse-a-stylesheet removes the first rule if it's @charset.

So it seems to me the following stylesheet parses without errors:

@charset { LOL }
foo { }

This seems bad at least for CSS validators but maybe also browser devtools that log CSS errors.

Note that HTML has some authoring conformance requirements on <meta charset> that are not parse errors in the parser section: https://html.spec.whatwg.org/multipage/semantics.html#character-encoding-declaration
Comment 1 Tab Atkins Jr. 2015-04-24 17:16:33 UTC
So I guess some authoring conformance criteria along the lines of "it's invalid to write a @charset rule that doesn't get recognized by the algorithm in this section" in #input-byte-stream?
Comment 2 Simon Pieters 2015-05-06 17:54:51 UTC
That's a bit vague, and maybe not helpful enough for implementors wanting accurate errors in the console. e.g. what about @charset "utf-16"; ? is whitespace in the string OK? What if HTTP charset is given and @charset says a different encoding? etc.