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.
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
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?
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.
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