abdfahim Posted September 12, 2010 Share Posted September 12, 2010 Hi, If I dont need to change anything inside a div (using getElementById), that is I have static content, should I still give ID to that DIV? I mean, what is recommended, giving ID to each DIV? or giving ID only to the DIVs where I need to access later (using getElementById)? Thanks, Quote Link to comment Share on other sites More sharing options...
ignace Posted September 12, 2010 Share Posted September 12, 2010 You should add a class to each div and an ID to those that require it (input, select, ..). Quote Link to comment Share on other sites More sharing options...
haku Posted September 12, 2010 Share Posted September 12, 2010 It really depends on the site. If you are coding the site yourself, then there is no need to give any IDs beyond the ones you need. If you are setting up a system whereby other people can/will be applying CSS rules, then it's best to give as many IDs for them to work with. Quote Link to comment Share on other sites More sharing options...
ignace Posted September 12, 2010 Share Posted September 12, 2010 If you are setting up a system whereby other people can/will be applying CSS rules, then it's best to give as many IDs for them to work with. I have to disagree, ID's aren't as flexible as classes can be due to it's single usage. Quote Link to comment Share on other sites More sharing options...
haku Posted September 12, 2010 Share Posted September 12, 2010 That's the whole point of an ID. Unless you are putting multiple footers on a page, it makes no sense to have class="footer". And without a footer ID, it won't be possible to only target elements in the footer. Quote Link to comment Share on other sites More sharing options...
abdfahim Posted September 14, 2010 Author Share Posted September 14, 2010 Thanks guys ... I think I get my answer from your discussion Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.