Can Classes and IDs be Numerical?

Discussion in 'CSS' started by Masterful, Mar 9, 2009.

  1. #1
    Can classes and IDs be numerical? For example:

    <div id="34">Content</div>
    
    #34 {
    margin:0;
    padding: 0;
    border: 1px solid #000;
    }
    Code (markup):
    Or:

    <div class="21">Content</div>
    
    .21 {
    margin:0;
    padding: 0;
    border: 1px solid #000;
    }
    Code (markup):
    It seems to be possible, having tried it. However, might some browsers have problems with it?
     
    Masterful, Mar 9, 2009 IP
  2. Joak1m

    Joak1m Peon

    Messages:
    135
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I remember, if you started class with number, it didn't work in Firefox, maybe it does now.
    So probably there might be some problems.
     
    Joak1m, Mar 10, 2009 IP
  3. sirkillalot

    sirkillalot Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Use letters and not numbers for class and for div.
     
    sirkillalot, Mar 10, 2009 IP
  4. spsseo

    spsseo Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    that was not the question

    I think its possible, but id will
    overwrite class if used together.
     
    spsseo, Mar 10, 2009 IP
  5. sirkillalot

    sirkillalot Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    nothing doesn't happen

    no problem if use ugual name for class and for id

    #name
    .name

    <div id="name">Content</div>

    <div class="name">Content</div>

    Are different, but dont use number for th name of div and class.


    .
     
    sirkillalot, Mar 10, 2009 IP
  6. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #6
    Doesn't matter if the browsers accept it or not. Numbers are not supposed to start identifiers. (hyphens aren't supposed to either). So if a browser does accept it, there's no guarantee it will always accept it.

    Look here for the details from the spec. :

    http://www.w3.org/TR/CSS21/syndata.html#characters

     
    shallowink, Mar 10, 2009 IP
    Masterful likes this.
  7. qazu

    qazu Well-Known Member

    Messages:
    1,834
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #7
    No, you need to start with a letter.
     
    qazu, Mar 10, 2009 IP
  8. Masterful

    Masterful Well-Known Member

    Messages:
    1,653
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    140
    #8
    Thanks for the responses, guys.

    Rep points given where deserved. ;)
     
    Masterful, Mar 10, 2009 IP
  9. wp-themes

    wp-themes Banned

    Messages:
    230
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #9
    That's a good question DP, never thought about it before ;)
    lol, have learned some thing from other members posts...
    Thanks goes to every one here.
     
    wp-themes, Mar 10, 2009 IP