Forum Moderators: not2easy

Message Too Old, No Replies

Improper Naming of CSS Styles Problem

         

Jon_King

5:56 pm on Dec 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is not really a NS problem per se, but as usual IE works just fine...

I inherited a site that uses styles with improper naming conventions - it has many styles starting with numerals. IE displays the styles fine, NS does not.

Does anyone have a way to change the name of a style sitewide and obviously update the code on all pages?

pageoneresults

7:09 pm on Dec 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hello Jon_King. I ended up down this path when I first started with css a couple of years ago. One of my first style sheets had all the classes beginning with numbers, eek!

I was just trying to find the exact reference at W3C concerning CSS and Class Naming Conventions but couldn't locate it. It pretty much says that you should not name your classes beginning with a number. This was a no-no in CSS1. Netscape ignores any classes that begin with a number.

The easiest way that I've found to correct this, is through a find and replace routine. First thing you'll need to do is carefully consider the names of your classes. Once you've determined the proper naming conventions, you'll then need to do your find and replace routine. It's going to be tedious, but if you have the right tools, it shouldn't take too long! ;)

Good luck!

Jon_King

10:21 pm on Dec 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I thought you were gonna say that.... I'd better get to work.

Thanks.

pageoneresults

10:30 pm on Dec 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm hoping Nick_W will chime in here and provide a link to the W3C reference on naming classes in css and not using a number in the first position of the class name. Best thing to do is to use only an alpha character as the first letter in your class name (a-z). You can then use numbers after that.

Jon_King

10:49 pm on Dec 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nick taught me this rule a few months ago when I had a similar problem, just not as big a problem as this current site. I believe he did quote the W3C.