March 17, 200917 yr Something has really annoyed me recently. My experience of id's and classes have always been, if you use more than one, its a class, if its unique, you use an id. Recently I had to integrate my html/css into a .net backend and I had to change 99% of my id's to classes because of the way .net selects them ( i am told). Is there any other reason to distinguish between id and classes so I dont get caught out again? Whats your working practice? Steve
March 17, 200917 yr You can use multiple classes at once, so generally classes win for me. Although id's always win on the whole specificity thing. Generally i think the biggest thing about id's an classes is the semantic information they carry, when you see id="nav" it tells you what it contains and that there is only one on the page, whereas class="box" tells you if you go fiddling with it, other elements will be affected. Although you can always use someing like <div class="box small left" to break the styles down, so box defines it's a box, small defines the sizes and then left defines the float. Anyway ramble, it sucks if you can't use classes, the reason above is the best part about them, the ability to use multiiple classes means you can break them down into some simple commands, so defining like 6 classes, allows you to make dozens of combinations.
Create an account or sign in to comment