Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

On CSS and other machinations.

by barrd (Parson)
on Oct 20, 2002 at 18:50 UTC ( #206692=monkdiscuss: print w/ replies, xml ) Need Help??

Dear fellow Monks,
As most of us know CSS (Cascading Style Sheets) are a great boon to any web site developer and can make 'themed' sites very easy to create and maintain. PM supports this by having either on-site markup or allowing a link to an external css file under your user settings. "All well and good", or so I thought. After much playing around two major things have come to light:

  1. CSS doesn't support underscores in the name (apparently?), for example:

    When I submitted the following snippet at (http://jigsaw.w3.org)

    tr.nodelet_head { font-weight : bold; color : #ff9933; background-color : #990000; }
    It produced the following error:

    Errors * Line: 5 Context : tr.nodelet Parse Error - nodelet_head { font-weight : bold; color : #ff9933; back +ground-color : #990000; }

    So that's one thing to bear in mind as the PM stylesheet (available by 'viewing source') contains quite a few elements named with an underscore. Whilst most browsers couldn't give a fig and either work or not, Mozzila routinely ignores any named elements with an underscore in the name causing unexpected results.

  2. After experementing I also found that not the whole PM site has been prepared for CSS, theres still quite a lot of hard coded areas where HTML elements have had their bgcolor set to blue/white as an example. And not to mention having gifs that haven't been given the transparency treatment. ;^)
So you're probably thinking "What a pedant"... or worse, at this point, well, I am and was wondering wether anyone else had come across the same problems? Do you reckon the Gods will hear this distant plea and come to my/our aid?

Thank you for listening to my rant.
Dave

Comment on On CSS and other machinations.
Select or Download Code
Re: On CSS and other machinations.
by sch (Pilgrim) on Oct 20, 2002 at 19:39 UTC

    Is there an introduction to CSS with PM anywhere? Obviously there's external stuff but I was wondering if anyone had written anything with a point to how PM could be themed and how the various CSS statements work?

    But today you took me walking, Through a land that we have lost,
    While our children sit at websites, With no access to the cost

      There may not be anything in PM, but someone pointed out W3 Schools to me in the CB and I wanted to recommend it :)

      But today you took me walking, Through a land that we have lost,
      While our children sit at websites, With no access to the cost

Re: On CSS and other machinations.
by Mission (Hermit) on Oct 21, 2002 at 13:40 UTC
    barrd,

    For some reason, Netscape (or Mozilla) doesn't allow for underscores in names of CSS or 'div' or any DHTML 'id' or 'name' attribute after their version 6 browser for Netscape and any Mozilla (that I'm aware of.) I've contacted them about this, and have had no luck in the getting them to admit it was a mistake, or something intentional for that matter.

    The only solution that I have (in order to make the CSS compatible with all browsers) is to avoid the underscore when naming CSS, or DHTML items.

    As soon as I read your opening statements, I knew where your post was heading. "Why did that happen?" In this case it's the choice of a browser developer. It has nothing to do with Perl, though I wish it was!

    For resources on CSS, you can visit some of the following web sites: All are valued resources.

    - Mission
      For some reason, Netscape (or Mozilla) doesn't allow for underscores in names of CSS or 'div' or any DHTML 'id' or 'name' attribute after their version 6 browser for Netscape and any Mozilla (that I'm aware of.)

      The reason Netscape & Mozilla don't allow "_" is that it's not legal CSS. See the appropriate dull bit from the spec.

      Not a bug :-)

      I lied. Underscores have been allowed since the 1998 errata.

Re: (nrd) On CSS and other machinations.
by newrisedesigns (Curate) on Oct 21, 2002 at 14:06 UTC

    You could aid the gods if you wouldn't mind fixing the errors/letting them know where they are.

    This isn't a really big issue, so just ask nicely and I'm sure they'll help.

    John J Reiser
    newrisedesigns.com

Re: On CSS and other machinations.
by joe++ (Friar) on Oct 21, 2002 at 15:58 UTC
    Hi barrd,

    Regarding your css example, I did a quick test with two recent builds of Mozilla (Build 2002091208/WinNT, 2002100104/Linux). A <div class="test_underscore"> was perfectly stylable through css.

    Looking some more at the Perlmonks code, I noticed that both th.nodelet_head and tr.nodelet_head are used. Specifying a generic class ".nodelet_head" doesn't work, as it is less specific than the original style specificatuions. Playing with Mozilla's DOM inspector is very helpful to debug CSS issues like this.

    My solution is simple (for Mozilla at least): add the "!important" qualifier to your styles, this will override more specific but "unimportant" styles.

    .nodelet_head { font-weight: bold !important; color: #ff9933 !important; background-color: #990000 !important; }
    This Works For MeTM.

    On a side note, there is no mention of "css" connected with "underscore" to be found in Bugzilla - so I don't think this is a bug, at least not with current builds.

    Update: Fixed a typo ;-(

    Update 2: Apparently, from the CSS level 2 syntax specification I seem to conclude that the underscore in style identifiers indeed is illegal. Still, this works just fine for IE 5.x+ and Netscape 6+ (Mozilla) in production code on the site I'm maintaining as well. Hmm, maybe I should fix that one day...

    --
    Cheers, Joe

Re: On CSS and other machinations.
by barrd (Parson) on Oct 21, 2002 at 17:19 UTC
    Thanks people for all the replies, I've gotten hold of some new ideas and links to play with. The main thing was (thanks to Mission) I realised that I wasn't going nuts... I'm going to read through it all and try and find a better way to do it.

    Update » thanks Joe++, I'd kinda come to the same conclusions, so I won't be using underscores in any of my naming conventions here-on-in, that should make things a tad easier for the future. And again, thanks for your reply.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://206692]
Approved by IlyaM
Front-paged by demerphq
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-12-25 15:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls