Closed Bug 12385 Opened 25 years ago Closed 17 years ago

CSS idents can't start with "-"

Categories

(Core :: CSS Parsing and Computation, defect, P3)

defect

Tracking

()

RESOLVED INVALID
Future

People

(Reporter: dbaron, Unassigned)

References

()

Details

(Keywords: css2, testcase, Whiteboard: [css2.1] (see comment 23))

Attachments

(1 file)

DESCRIPTION: CSS2 identifiers can't start with dash (0-9 and - are the characters that can't start an identifier but can be in the middle). I know you're using -moz to begin identifiers that represent extensions, but (unless this will be changed in CSS3), you shouldn't allow classes, etc., that begin with a -. That is: .-d { font-weight: bold; } should be ignored. STEPS TO REPRODUCE: Load above URL. ACTUAL RESULTS: Fifth bulleted item has two words in bold. EXPECTED RESULTS: Fifth bulleted item should not have any words in bold. DOES NOT WORK CORRECTLY ON: * Linux, apprunner, 1999-08-20-13-M10
ALSO DOES NOT WORK CORRECTLY ON: * Windows, apprunner, 1999-08-24-09-M10
CSS3 allows idents to start with dashes (explicitly to allow the extension mechanism). Need to evaluate if this should apply to class names (and a few other places where ident is allowed.
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → LATER
Status: RESOLVED → VERIFIED
Verifying this LATER.
Summary: CSS idents can't start with - → {css1} CSS idents can't start with "-"
Summary: {css1} CSS idents can't start with "-" → {css1} {css3} CSS idents can't start with "-"
Reassigning peterl's latered bugs to myself.
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 25 years ago25 years ago
Is this still latered? If not, please remove resolution. If not, I will verify it again.
Whiteboard: css syntax
Yep, still latered. In case we (er... when we) look into it again, Ian posted some useful info about errata to the CSS syntax under bug 18936.
Status: RESOLVED → VERIFIED
Verified LATER.
Keywords: css1
Migrating from {css1} to css1 keyword. The {css1}, {css2}, {css3} and {css-moz} radars should now be considered deprecated in favour of keywords. I am *really* sorry about the spam...
Keywords: css3
Reopening and moving to Future...
Status: VERIFIED → REOPENED
Resolution: LATER → ---
Summary: {css1} {css3} CSS idents can't start with "-" → CSS idents can't start with "-"
Target Milestone: --- → Future
I think it would be nice, if it would have an milestone (instead of Future) assigned since Mozilla claims to support CSS fully. See also: http://www.w3.org/Style/CSS/Test/current/sec15.htm and specs: http://www.w3.org/TR/REC-CSS2/syndata.html#q4
Attached file testcase
added testcase
Summary: CSS idents can't start with "-" → CSS idents can't start with "-" [SELECT]
Whiteboard: css syntax → css syntax; wg
Tried http://www.w3.org/Style/CSS/Test/current/sec15.htm on Mac OS 9.0.4, Mozilla build 2000100208-M18, still doesn't work. (CSS1 Test Suite: 1.5 ID as selector)
Netscape's standard compliance QA team reorganised itself once again, so taking remaining non-tables style bugs. Sorry about the spam. I tried to get this done directly at the database level, but apparently that is "not easy because of the shadow db", "plus it screws up the audit trail", so no can do...
QA Contact: chrisd → ian
Changing URL to my test suite since my publisher modified its web site architecture w/o notification :-(
Whiteboard: css syntax; wg → [Hixie-P4] css syntax; wg
Whiteboard: [Hixie-P4] css syntax; wg → [Hixie-P4][CSS1-B] css syntax; wg
Assigning pierre's remaining Style System-related bugs to myself.
Assignee: pierre → dbaron
Status: REOPENED → NEW
Has the WG decided anything here yet?
> Has the WG decided anything here yet? I don't know, but they have at *not* allowed the '-' character in the CSS 2.1 WD, released ~a week ago <URL: http://www.w3.org/TR/2002/WD-CSS21-20020802/grammar.html >.
Yes... but this is not a CSS2 issue. This is a question of what CSS3 will say (since CSS2 also does not have the -vendor-ident mechanism in place).
Status: NEW → ASSIGNED
Keywords: qawanted, testcase
Summary: CSS idents can't start with "-" [SELECT] → CSS idents can't start with "-"
Yeah, at this point this looks invalid.
"Only properties, values, units, pseudo-classes, pseudo-elements, and at-rules may start with a hyphen (-); other identifiers (e.g. element names, classes, or IDs) may not." (4.1.3)
To summarize: this is a valid bug, since Mozilla supports something it should not support (.-d).
Keywords: css1, css3, qawantedcss2
Whiteboard: [Hixie-P4][CSS1-B] css syntax; wg → [css2.1] (see comment 23)
hmm iirc recently we had a problem with calendar class names (which started with '-' iirc we warn about it in debug builds, perhaps we can make the warning into an error?
Assignee: dbaron → nobody
Status: ASSIGNED → NEW
QA Contact: ian → style-system
Latest CSS 2.1 WD (06 November 2006) suggests that IDs can start with an hyphen (-) and then may be followed by an alphabetic character [A-Za-z] or may then even be followed by an underscore (_). { In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-z0-9] and ISO 10646 characters U+00A1 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, or a hyphen followed by a digit. } CSS 2.1, Working Draft 06 November 2006, Section 4.1.3 Characters and case http://www.w3.org/TR/CSS21/syndata.html#q6 { ident -?{nmstart}{nmchar}* nmstart [_a-z]|{nonascii}|{escape} } CSS 2.1, Working Draft 06 November 2006, G.2 Lexical scanner http://www.w3.org/TR/CSS21/grammar.html#q2 To make things worse, CSS 2.1, Working Draft 06 November 2006, section G.3 Comparison of tokenization in CSS 2.1 and CSS1 at http://www.w3.org/TR/CSS21/grammar.html#tokenizer-diffs says { In CSS1, a class name could start with a digit (".55ft") } while CSS 1 spec says { in CSS1, selectors (element names, classes and IDs) can contain only the characters A-Z, 0-9, and Unicode characters 161-255, plus dash (-); they cannot start with a dash or a digit; } http://www.w3.org/TR/REC-CSS1#css1-conformance Finally, HTML 4.01 claims that { ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). } http://www.w3.org/TR/html4/types.html#type-id Did I miss something? I'm voting for this bug :)
Example: <p id="-asdf"> Both the HTML 4.01 spec and W3C HTML validator say this attribute value is invalid but #-asdf { color: red } is fine and ok with latest CSS 2.1 WD and with the W3C CSS validator
We pass that testcase, no?
If we meticulously follow and comply with the latest CSS 2.1 (6 nov. 2006) WD, then yes, we pass that testcase. I wish all CSS 2.1 WD would not have introduced exceptions and unneeded complexity and just carried on with the CSS1 and simple "selectors (element names, classes and IDs) (...) can not start with dash or digit". Those kind of new CSS 2.1 exceptions encourage and promote invalid markup code as invalid attribute specifications are to be honored nevertheless in CSS 2.1.
FYI: There is a CSS 2.1 test that fails that is, I believe, from this bug. The source has: .one { color: green; background: white; } .-ident, .one { color: red; } .two { color: green; background: white; } #-ident, .two { color: red; } In both cases, the text should be green, but it is red. http://www.w3.org/Style/CSS/Test/CSS2.1/current/t040103-ident-03-c.htm Looking at: http://www.w3.org/Style/CSS/Test/CSS2.1/current/t040103-ident-00-c.htm ... http://www.w3.org/Style/CSS/Test/CSS2.1/current/t040103-ident-13-c.htm All the others pass.
Ray, The previous and current/latest [July 19th 2007, CR] CSS 2.1 spec says: "in CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-z0-9] and ISO 10646 characters U+00A1 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, or a hyphen followed by a digit." http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier Also, current (and previous) CSS 2.1, Section 4.1.1 Tokenization http://www.w3.org/TR/CSS21/syndata.html#tokenization still gives ident [-]?{nmstart}{nmchar}* nmstart [_a-z]|{nonascii}|{escape} So, they can start with an hyphen as long as their next character is not a digit. E.g.: 1- id="-_" #-_ {color: red;} is perfectly valid CSS 2.1 2- id="-foo" #-foo {color: red;} is perfectly valid CSS 2.1 3- class="-bar" .-bar {color: red;} is also perfectly valid CSS 2.1 and so is -ident since "i" is not a digit. This is the CSS validator report according to CSS 2.1 profile of the t040103-ident-03-c.htm webpage: http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.w3.org%2FStyle%2FCSS%2FTest%2FCSS2.1%2Fcurrent%2Ft040103-ident-03-c.htm&warning=2&profile=css21&usermedium=all As far as I can see, both sentences in http://www.w3.org/Style/CSS/Test/CSS2.1/current/t040103-ident-03-c.htm should be red, not green. That test needs to be updated.
As far as I'm concerned, - this bug should be resolved as WORKSFORME, - the summary should be updated so that we don't mislead bug reporters - I. Hickson should also be informed that one of his test CSS2.1/current/t040103-ident-03-c.htm may not be correct.
The restriction on starting hyphens in identifiers was removed. The resolution was for issue 167 in issues-3, in response to http://lists.w3.org/Archives/Public/www-style/2006Mar/0068.html The discussion is minuted in http://lists.w3.org/Archives/Member/w3c-css-wg/2006JulSep/0006.html where it basically says there's interop on supporting hyphens at the beginning of class names and the restriction is confusing anyway. Marking INVALID.
Status: NEW → RESOLVED
Closed: 25 years ago17 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: