Iain Harrison wrote:
Friday, November 12, 2004, 7:23:40 PM, Ben wrote:

Could be wrong here, or just showing my age, but I recall standards in
1999 saying that underscores were forbidden in class and id names.

I think they were always legal in css as long as they weren't at the beginning of the name.

However, I'm fairly sure that there is an issue with underscores in
class names in the html

From the Dec '96 CSS1 spec, under 7.1 Forward-compatible parsing:

"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; they can also contain escaped
characters and any Unicode character as a numeric code"

There's no apparent change to this in the May '98 CSS2 spec.

Then, in the Feb '04 CSS2.1 spec, under 4.1.3 Characters and case:

" In CSS 2.1, identifiers  (including element names, classes, and IDs in
selectors) can contain only the characters [A-Za-z0-9] and ISO 10646
characters U+00A1 and higher, plus the hyphen (-) and the underscore
(_); they cannot start with a digit. 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.
Identifiers can also contain escaped characters and any ISO 10646
character as a numeric code"

This change is listed under Appendix C Changes, point 3.3

"The underscore is allowed in identifiers. Changed "In CSS2, identifiers
[...] can contain only the characters [A-Za-z0-9] and ISO 10646
characters 161 and higher, plus the hyphen (-)" to:

    In CSS2, identifiers [...] contain only the characters [A-Za-z0-9]
and ISO 10646 characters 161 and higher, plus the hyphen (-) and the
underscore (_)"


Personally, I avoid them, because I'm not sure where the problem is - perhaps your question will flush out the answer that has eluded me for so long!


Did some really small superficial test to see which older browsers support underscores in class names:
- IE 4 no
- IE 5, 5.5 yes
- Netscape 4.77 yes (surprisingly)
- Netscape 6 no
- Netscape 7 yes


(obviously this list is far from complete)


While I was at it, also tested support for multiple class names (e.g. class="warning notice" referring to .warning and .notice simultaneously): - IE 4 no - IE 5, 5.5 yes - Netscape 4.77 no - Netscape 6, 7 yes


Patrick H. Lauke _____________________________________________________ re·dux (adj.): brought back; returned. used postpositively [latin : re-, re- + dux, leader; see duke.] www.splintered.co.uk | www.photographia.co.uk http://redux.deviantart.com


****************************************************** The discussion list for http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************



Reply via email to