October 13th, 2001, 12:15 PM
HTML / CSS identifiers
"_" (underscore) is a natively valid character in HTML identifiers. Brilliantly, it is not a natively valid character in CSS identifiers. However, you can indicate the underscore in a CSS identifier by using a hexadecimal Unicode escape sequence (\00005F).
So, I have an HTML document that has elements with underscore in the identifier (e.g. 'SECTION_QUALIFICATIONS') and I have a stylesheet where I reference those identifiers, using the escape sequence in place of the underscore (i.e. 'SECTION\00005FQUALIFICATIONS'). This works as expected in NS 6.1, but it is not working in IE 5.0 (I could swear it was last night...). If I use the actual underscore character in the stylesheet instead of the escape sequence, it works in IE 5.0, but I'm not going to do that because it's not valid CSS and the whole point of what I'm doing is to make a W3 valid page.
Does anyone know anything about this? Is it simply IE 5.0 being f'ed up and not properly supporting CSS? I just did a little experiement and I can see that IE is not properly handling the escape sequences; I left the stylesheet with the escapes and changed the identifier of an element, replacing the literal underscore with the escape sequence \00005F, then things worked in IE.
So does anyone know why IE would not parse the escape sequences? Is this a character encoding issue (I'm using UTF-8)?
Any help with this appreciated. It's going to be galling if this can't be resolved, because all of the stuff I'm actually doing with CSS works, and I really don't want to change my elements' identifiers.
October 16th, 2001, 05:15 PM
October 16th, 2001, 05:22 PM
With some experimentation, I find that an underscore in IE and NS6 is
October 18th, 2001, 07:33 PM
Thanks for responding Nemi. I'm not sure what you're describing, \u005F did nothing for me in either browser. Anyway, after I made this post, I continued my research and eventually found my way into the CSS2 errata, which revealed that the underscore is supposed to be allowed in identifiers. Apparently this isn't (yet?) reflected in the W3 CSS validator though. As for the escape sequences, according to the spec, this is the syntax:
Netscape 6 properly evaluates the escape sequence, IE 5 does not. But the literal underscore is allowed, thank god.
October 18th, 2001, 11:21 PM
Cool, I am glad you got it working. What I did was something like:
That puts an underscore in an alert when the page loads in either IE or NS6. I didn't go all out and do it with identifiers though.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
October 19th, 2001, 10:31 AM
Oh, OK, I see what you mean. In CSS everything is Unicode, so the escapes are just \###### (# = Hexadecimal digit), or the alternate form.