SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist mumford1's Avatar
    Join Date
    Sep 2002
    Location
    UK
    Posts
    569
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Difference between ID and CLASS

    Hi

    I ahve seen a few style sheets now that use classes such as div id="maincontent" what is the difference in using id as oppose to class

    also what is number character for between div and container
    below

    DIV#container {
    MARGIN: 1em auto 0px; BORDER-LEFT: black 1px solid; WIDTH: 770px; POSITION: relative; BACKGROUND-COLOR: #e6eef7
    }

    thanks alot

  2. #2
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,811
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Divs are effectively unique - not reusable enitities, whereas classes are "types" of area's, and can be recycled.

    The Hash/Number/Pound symbol is identical in function for divs as the "." is for classes...

    ie:

    div#container {
    }

    represents the values of the div named container (so you'd use <div id="container"> just as,

    .container {
    }

    could be used for <span class="container">
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  3. #3
    jigga jigga what? slider's Avatar
    Join Date
    Oct 2002
    Location
    Utah (USA)
    Posts
    309
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When H says div, substitute id and you'll get what he means...

    A class is reusable. An id is not. On any page you can only have one div with an id of id1. But you can have as many div's with a class of class1 as you want.

    That's the main difference.
    $slider = 'n00b';


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
  •