#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Location
    Lahore, Pakistan
    Posts
    7
    Rep Power
    0

    Difference between classes and IDs ?


    Hello,


    I am new to this html and CSS learning and I am using code academey website for learning CSS and HTML, I just need to know what is the difference between Classes and IDs in CSS ?


    Please explain
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    25
    Rep Power
    0
    u mean how to address it?
    #idName and .className

    or the idea/meaning behind a class/id?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Location
    Lahore, Pakistan
    Posts
    7
    Rep Power
    0
    Actually I was asking the idea behind or meaning of id and classes . As these are both used for styling in CSS so how we get to know about adding a class or id in html ? Means classes and IDs are different from each other in what sense ?
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    25
    Rep Power
    0
    Originally Posted by furki
    Actually I was asking the idea behind or meaning of id and classes . As these are both used for styling in CSS so how we get to know about adding a class or id in html ? Means classes and IDs are different from each other in what sense ?
    Id means an (hopefully) unique identifier for an element. A class defines a group of elements with common styleattributes.

    For example if you have several divs in ur page which should get a border, u use a class and define the borderstyle for the class.

    If you need to access a special element (inputfield etc.) u assign an id to it so u can access it directly from JS.

    Same if you need to apply a style to one special element. Than u assign an id and define the corresponding style in the css better than do an inline style definition.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    862
    Rep Power
    275
    Let Me Google That For You

    Comments on this post

    • mythos_ agrees
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Location
    Lahore, Pakistan
    Posts
    7
    Rep Power
    0
    thanks dear for this explanation, actually I knew I can google it and get the answer but i was trying here thinking someone may give me better answer than google. I have googled as well and got the answer too.

    Thanks a lot

IMN logo majestic logo threadwatch logo seochat tools logo