Results 1 to 2 of 2

Thread: Using punctuation in DIV and .class names

  1. #1
    Join Date
    May 2006
    Posts
    275

    Using punctuation in DIV and .class names

    Can someone steer me in the right direction? I have been using underscores and dashes in my CSS selector names all along without any problems, but am now reading a book by Zeldman that says underscores aren't recognized in CSS2 and dashes are illegal.

    I spent five minutes Googling this and didn't find exactly what I wanted - can someone link me or spell out the rules on file names & punctuation/numbers?

  2. #2
    Join Date
    Feb 2006
    Location
    Salisbury UK
    Posts
    4,332
    I have been told that dashes are illegal in some scripts, but not css2 as far as I know.

    Re selectors, I found this regarding CSS1 which says underscores are illegal:-
    http://lists.evolt.org/archive/Week-...11/106623.html

    Re CSS2 selectors see this:-
    http://www.nic.fi/~tapio1//Teaching/Valitsimet1.php3
    You can use also number + hyphen, but you can't start with them.
    The name must start with a normal letter (a-z,A-Z). Accepting the underscore (_) has been afterward added into CSS2.

    See also the official CSS2 changes:-
    http://www.w3.org/TR/CSS21/changes.html
    The underscore character ("_") is allowed in identifiers.

    Note the different way browsers render it:-
    http://www.thefixor.com/help/cssfaq.php

    -------------------------
    I believe underscores are still valid in urls but undesirable as many links have an underline which obscures the underscore. There have been situations where someone writes down or reads out a url to a colleague assuming a space which is really an underscore and the url when later used is no good.

    Both should be avoided in my view.

    I found this interesting, (it didn't say either is invalid):-
    http://www.simoncox.com/mt3/2006/06/...nderscores.php
    Last edited by Wickham; 09 Aug 2006 at 10:53 AM.
    Code downloaded to my PC will be deleted in due course.
    WIN7; IE9, Firefox, Opera, Chrome and Safari for Windows; screen resolution usually 1366*768.
    Also IE6 on W98 with 800*600 and IE8 on Vista 1440*900.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •