By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,223 Members | 1,395 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,223 IT Pros & Developers. It's quick & easy.

css clas names allowed to have - but not _ ?

P: n/a
I was reading some old groups.google.com posts about css class names not
being allowed underscores, but hyphens are?

Why exactly did the writers/drafters of the spec think this was better
then allowing underscores? Most any programming languages alow _'s in
identifiers and NOT -'s, like Java, C, C++, Perl, ASP, PHP, JavaScript,
hell even Pascal.

Why did the turn around something most developers were/are customed to
when thye drafted the css specs? Almsot seems liek this was put in there
to purposely piss us off. (I just spent a good hour changing names in
our css code that has _'s to -'s because NN4 and some Mozzilla versions
choked on them.)

Thanks.
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Damian wrote:
(I just spent a good hour changing names in
our css code that has _'s to -'s because NN4 and some Mozzilla versions
choked on them.)


Find & Replace could have done that for you in no time at all.

--

Barbara

http://home.wanadoo.nl/b.de.zoete/html/weblog.html
http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html

Jul 20 '05 #2

P: n/a
in post: <news:bv************@ID-196529.news.uni-berlin.de>
"Damian" <no********@adress.getting.too.much.spam.org> said:
I was reading some old groups.google.com posts about css class names not
being allowed underscores


corrected in the errata but not part of the spec
http://www.w3.org/Style/css2-updates...12-errata.html

--
brucie - i usenet nude
Jul 20 '05 #3

P: n/a
On Wed, 28 Jan 2004, brucie wrote:
in post: <news:bv************@ID-196529.news.uni-berlin.de>
"Damian" <no********@adress.getting.too.much.spam.org> said:
I was reading some old groups.google.com posts about css class names not
being allowed underscores
corrected in the errata but not part of the spec


Substantively changed in the errata, or purported to be (errata aren't
supposed to do that, but they didn't seem to care); as you say, the
change isn't officially part of the spec, but see draft CSS2.1.
http://www.w3.org/Style/css2-updates...12-errata.html


I think the hon Usenaut might also have been interested in why it was
so. Originally the idea was that names in HTML would be SGML name
tokens, and they're defined to start with a letter and then use
letters, digits and hyphen-minus. Nothing else.

Since CSS class and id names are referencing name attributes in an
SGML-based markup such as HTML, they were originally happy with a set
of rules for CSS that matched the rules for HTML...

However, both HTML and CSS subsequently got much more lenient about
what characters could be used in names. But most of the extra
characters have to be escaped if you want to use them in CSS.

For a latin-based language it's much easier to stick with the simplest
subset, if the choice is yours. I think W3C were worried that authors
writing Japanese or whatever would complain that they weren't allowed
to write their name attributes in their own language, and would then
accuse the W3C of being too English-centric.

Jul 20 '05 #4

P: n/a
Barbara de Zoete wrote:
Damian wrote:
(I just spent a good hour changing names in
our css code that has _'s to -'s because NN4 and some Mozzilla
versions choked on them.)


Find & Replace could have done that for you in no time at all.


Yes, but it was quite cumbersome having to keep "Find Next"ing whne
fishing through Perl code that prints soem html to a shtml page (sorta
liek a PHP or ASP script.) ;p
Jul 20 '05 #5

P: n/a
It seems "Alan J. Flavell" wrote in
comp.infosystems.www.authoring.html:
I think the hon Usenaut might also have been interested in why it was
so. Originally the idea was that names in HTML would be SGML name
tokens, and they're defined to start with a letter and then use
letters, digits and hyphen-minus. Nothing else.


You knew someone would ask a follow-up question, so let it be me:

Why were SGML names defined in that fashion, allowing minus but
disallowing underscore?

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #6

P: n/a
Stan Brown <th************@fastmail.fm> wrote:
It seems "Alan J. Flavell" wrote in
comp.infosystems.www.authoring.html:
I think the hon Usenaut might also have been interested in why it was
so. Originally the idea was that names in HTML would be SGML name
tokens, and they're defined to start with a letter and then use
letters, digits and hyphen-minus. Nothing else.

Actually SGML allows the period (full stop, ".") character in names
as well by default, i.e. in the reference concrete syntax (Ref.:
ISO 8879, clause 9.2.1), and HTML has done so from the beginning, see
http://www.w3.org/MarkUp/html-spec/h....html#SEC3.2.3

In a class name, a period is a particularly poor choice in practice,
however. It is true that it can be used in a class name in CSS too, but
then it needs to be escaped somehow (e.g. as \.) to avoid
interpretation as being part of selector syntax.
You knew someone would ask a follow-up question, so let it be me:

Why were SGML names defined in that fashion, allowing minus but
disallowing underscore?


I cannot find any quick direct answer to that in the SGML Handbook, but
then again who has ever found a quick direct answer there? :-) But my
half-educated guess is that "-" was regarded as a character that is
surely available in all circumstances and more natural-looking than the
underscore. After all, the underscore (underline, "_") character was
originally taken into Ascii to be used for underlining (together with
the control character for backspace or carriage return), though it - as
well as other special characters - were later taken into use as a
special name character in programming languages and other notations.
(To be exact, it originally had a dual purpose, including a control
function in teleprinters as the other usage, see
http://www.cs.tut.fi/~jkorpela/latin...i-hist.html#5F )

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.