CSS idents can't start with "-"

RESOLVED INVALID

Status

()

Core
CSS Parsing and Computation
P3
normal
RESOLVED INVALID
18 years ago
5 months ago

People

(Reporter: dbaron, Unassigned)

Tracking

({css2, testcase})

Trunk
Future
css2, testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

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

Attachments

(1 attachment)

213 bytes, text/html
Details
(Reporter)

Description

18 years ago
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
(Reporter)

Comment 1

18 years ago
ALSO DOES NOT WORK CORRECTLY ON:
 * Windows, apprunner, 1999-08-24-09-M10

Comment 2

18 years ago
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
Last Resolved: 18 years ago
Resolution: --- → LATER

Updated

18 years ago
Status: RESOLVED → VERIFIED

Comment 3

18 years ago
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 "-"

Comment 4

18 years ago
Reassigning peterl's latered bugs to myself.

Updated

18 years ago
Status: NEW → ASSIGNED

Updated

18 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 18 years ago18 years ago

Comment 5

18 years ago
Is this still latered? If not, please remove resolution. If not, I will verify
it again.

Updated

18 years ago
Whiteboard: css syntax

Comment 6

18 years ago
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.

Updated

18 years ago
Status: RESOLVED → VERIFIED

Comment 7

18 years ago
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

Comment 10

17 years ago
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

Comment 11

17 years ago
Created attachment 13574 [details]
testcase

Comment 12

17 years ago
added testcase
Summary: CSS idents can't start with "-" → CSS idents can't start with "-" [SELECT]
Whiteboard: css syntax → css syntax; wg

Comment 13

17 years ago
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
(Reporter)

Comment 16

15 years ago
Assigning pierre's remaining Style System-related bugs to myself.
Assignee: pierre → dbaron
Status: REOPENED → NEW
Has the WG decided anything here yet?

Comment 18

15 years ago
> 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).
(Reporter)

Updated

15 years ago
Status: NEW → ASSIGNED

Comment 20

14 years ago
CSS2.1 does: <http://www.w3.org/TR/2004/CR-CSS21-20040225/syndata.html#q4>
Keywords: qawanted, testcase
Summary: CSS idents can't start with "-" [SELECT] → CSS idents can't start with "-"
Yeah, at this point this looks invalid.
(Reporter)

Comment 22

14 years ago
"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)

Comment 23

14 years ago
To summarize: this is a valid bug, since Mozilla supports something it should
not support (.-d).

Updated

13 years ago
Keywords: css1, css3, qawanted → css2
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?
(Reporter)

Updated

10 years ago
Assignee: dbaron → nobody
Status: ASSIGNED → NEW
QA Contact: ian → style-system

Comment 25

10 years ago
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 :)

Comment 26

10 years ago
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

Comment 27

10 years ago
Complete testcase for this bug:

http://www.gtalbot.org/BrowserBugsSection/MSIE7Bugs/CSS1ForwardCompatibleParsing.html
We pass that testcase, no?

Comment 29

10 years ago
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.

Comment 30

10 years ago
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.

Comment 31

10 years ago
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.

Comment 32

10 years ago
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.

Comment 33

10 years ago
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
Last Resolved: 18 years ago10 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.