Skip to main content

id vs class - CSS usage

This is a common question on css- ID vs Class.


The key thing to know is that IDs identify a specific element and therefore must be unique on the page - you can only use a specific ID once per document. Many browsers do not enforce this rule but it is a basic rule of HTML/XHTML and should be observed. Classes mark elements as members of a group and can be used multiple times, so if you want to define a style which will be applied to multiple elements you should use a class instead.

Also, an element can have multiple class values (by space-separating the various values), while an ID must be a single value. In this way, a single element can "inherit" from multiple classes.


Comments

Popular posts from this blog

Software way of milking cow: ( I got this through mail... Intersting ) Softwarism:(Ultimate....) If Client has 2 cows and u need to milk them 1 .. First prepare a document when to milk them (Project kick off) 2 .. Prepare a document how long you have to milk them (Project plan) 3 .. Then prepare how to milk them (Design) 4 .. Then prepare what other accessories are needed to milk them (Framework) 5 .. Then prepare a 2 dummy cows (sort of toy cows) and show to client the way in which u will milk them (UI Mockups & POC) 6 .. If client is not satisfied then redo from step 2 7 .. You actually start milking them and find that there are few problem with accessories. (Change framework) 8 .. Redo step 4 9 .. At last milk them and send it to onsite. (Coding over) 10. Make sure that cow milks properly ( Testing) 11. Onsite reports that it is not milking there. 12. You break your head and find that onsite is trying to milk from bulls 13. At last onsite milk them and send to client (Testing) 1...

How to deselect all the selection in a select ( combo ) box?

In a HTML page sometimes we may have to deslect all the selection in a select control of html. but as a user we can't do anything. But using Javascript programatically we can achieve this. Here is the sample code in Javascript. function clearSelect( selectObj ){ for (var i = 0; i selectObj .options[i].selected = false; } } note: we need to pass the select object as a parameter to this function. the alternative to this code is function clearSelect( selectObj ){ selectObj.selectedIndex = -1; }