Class and identifier question, Please advice

Discussion in 'CSS' started by kojakfilth, Jul 16, 2007.

  1. #1
    Hi guys im confuse on what to use.. Please give me more assistance to whats the best to use between class and identifier at css..

    Please advice.

    Kojak
     
    kojakfilth, Jul 16, 2007 IP
  2. daytona_k

    daytona_k Well-Known Member

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    116
    #2
    i presume that you are talking about using .class vs #id right?
    it's pretty simple
    #id can be used only one time in a page's code.
    for example, you can use is for a big div, enclosing all the information of the page, like < div id="someid" > ... whole content < / div >

    .class can be used multiple times....like for some list elements...

    < li class="someclass"
    < li class="someclass"
    < li class="someclass"

    etc...
     
    daytona_k, Jul 16, 2007 IP
  3. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The value of an ID can only be used, but you can have multiple ID attributes.

    I prefer IDs to classes, unless there are specific sections of a block that have to be styled differently from the rest. But even then, I'll use IDs and classes sparingly, instead preferring to let the stylesheet grab the elements of a page based on their parents. This does take some experience, but is well worth learning.
     
    Dan Schulz, Jul 16, 2007 IP