Results 1 to 2 of 2

Thread: Differences between using "id" & "class"

  1. #1
    Join Date
    Nov 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Differences between using "id" & "class"

    What is the difference between...

    #something
    {
    }

    <div id="something"></div>

    .somethingelse
    {
    }

    <div class="somethingelse"></div>

    When would one be used over the other and vice/versa?

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Code:
    #something{
    
    }
    The above item is known as ID Selector. The idea is you can use this ID Selector only on a single HTML element as its ID. ID is supposed to be a unique value within a web page. In other words you can use the above mentioned item only once.

    Code:
    .somethingelse
    {
    }
    The above is the class selector. The advantage of this over the ID selector is you can re-use this class on any number elements using the 'class' attribute of that element which needs to use the CSS class.

Bookmarks

Posting Permissions

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