Jump to content

giving DIV a ID is good practice?


abdfahim

Recommended Posts

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,

Link to comment
https://forums.phpfreaks.com/topic/213195-giving-div-a-id-is-good-practice/
Share on other sites

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.