Shoukat_1983 Posted April 13, 2006 Share Posted April 13, 2006 In the tutorials i have studied the selectors like class selector and id selector but i didn't understand the differnce between them? Also how can we call the id selectors in any tag? Calling the class selectors have been mentioned and explained in tutorial but not calling id Selectors. Link to comment Share on other sites More sharing options...
Jonas Posted April 13, 2006 Share Posted April 13, 2006 Class selectors can be used multiple times, on more than one element. You give a class css properties like this:.class_name {css properties}Id selectors on the other hand are used only once for one document, so you can only have one element with that particular id name. To give an id css properties, you type:#id_name {css properties}Look at the source code of this forum. Search for id="ipbwrapper". You'll only find one. Now do a search for class="row1". More than one is used. Classes are useful particularly on elements where you have several similar elements, but you want some of them styled the same, and others differently, and so css declaration by inheritance wouldn't work.table#id_name td {css properties}That would give the same styling to all <td> elements found between the <table id="id_name">. Should you want to style some differantly, you would give them a class:table#id_name td.class_name {css properties}or simplytd.class_name {css properties} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now