1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Difference between Div, ID,Class,and Name?

Discussion in 'CSS' started by diam26, Sep 1, 2008.

  1. #1
    Hi,
    Dear friends, I am learning Css and I am confused with ID,Class,and Name. Can some one explain me what is the difference between them in Css?
    Where and when we should use the Div, ID,Class and Name? If possible please explain me with few examples. I am really confused. Why some people using the Div.h1 while some use ; #h1? Please explain me why and when we should use these tags.
    thanks.
     
    diam26, Sep 1, 2008 IP
  2. mypsdtohtml

    mypsdtohtml Guest

    Messages:
    96
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    div uses # and you use div to create areas in the site
    you use classes and classes uses a dot more likely for fonts, colors, borders

    div is always liked to an ID and classes are not linked to id's

    another thing with classes is you can use a class in many parts of your website where div define areas

    re-h1,h2, etc they NEVER use a # before, they are unique elements and you just write them in the CSS as h1 {etc.... }

    Hope that helps and please if you like this explanation it might be nice if you write a good review for me in order to have a better reputation in this site

    thanks
     
    mypsdtohtml, Sep 1, 2008 IP
  3. diam26

    diam26 Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ID VS CLASS


    Dear Friend,
    Thank you so much for your info. You have explained well regarding the question. I really appreciate for your kind info.

    So what is the different between Id and Class? I understand that we use class in the Div. but why some people use ID instead Class?


     
    diam26, Sep 1, 2008 IP
  4. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #4
    ID as a unique name applied to one element on a page. No other element has that same name.
    Class is a name applied to a group of elements that share the same attributes.

    An analogy is that of a school room. Each student has their own unique id for themself in Mrs. Folger's class but there are many students that belong to that class. If Mrs. Folger says Bobby Smith gets the dunce cap that day, only Bobby Smith gets it. But if the principal says Mrs. Folger's class gets gold stars, then all the students get gold stars.
     
    drhowarddrfine, Sep 1, 2008 IP
  5. lilac2

    lilac2 Peon

    Messages:
    367
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    h1 {}
    Code (markup):
    Formats all heading 1 in this style

    #page
    Code (markup):
    <div id="page"></div>
    Code (markup):
    Sets a CSS region

    #page h1
    Code (markup):
    Formats all heading 1 inside the "page" id div in this style
     
    lilac2, Sep 1, 2008 IP