Ok, so I've been using ID attributes more and more in my HTML.
I've gotten to the point where I'll ID any div that is unique and needs to be styled... whether or not it is something that needs to be referenced by javascript.
I'll typically do stuff like this:
My issue is that I'm not sure all of the ID'ed elements things should be ID'ed. Are there any standards you guys use to determine what's an ID and what's a CLASS, other than whether it will be repeated?Code:<body> <div id="wrapper"> <div id="page"> <div id="header"> <div id="logo"></div> <div id="menu"></div> </div> <div id="main"> <div id="left"> <div class="block"> <div class="blockHeader"> </div> <div class="blockBody"> </div> <div class="blockFooter"> </div> </div> </div> <div id="right"> <div id="content"> </div> </div> </div> <div id="footer"> </div> </div> </div> </body>
The reason this came up is because I was considering adding some AJAX functionality to a site today and I was considering using DOM to append to an element... so then I was thinking, "do I really want the style of that element to depend on its id?"
For example, let's say I want to do something like this:
Well now I've got the element styled by its class and referenced by its id. That's how it should be.Code:<body> <table id="merchantList" class="list"> </table> </body>
But what if I want to add dynamism to other elements?
What I'm beginning to think is that element identifiers like "header", "footer", "left", and "right" should be classes, because it's feasible (even though very unlikely) that they could be repeated and have unique ID'ed instances thereof, such as <div class="header" id="mainHeader"> (for whatever odd reason).
Anyone else thinking the same thing?