March 24th, 2013, 11:25 AM
Difference between classes and IDs ?
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 ?
March 24th, 2013, 12:03 PM
u mean how to address it?
#idName and .className
or the idea/meaning behind a class/id?
March 24th, 2013, 12:42 PM
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 ?
March 24th, 2013, 12:50 PM
Id means an (hopefully) unique identifier for an element. A class defines a group of elements with common styleattributes.
Originally Posted by furki
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.
March 24th, 2013, 01:07 PM
March 24th, 2013, 02:14 PM
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