re: Reasons not to use IDs in CSS VIEW POST


I just like to remind all who read this that this pice is someone's opinion and is disputed as to whether or not "avoiding" IDs in your HTML/styling should ultimately be avoided as some sort of "best practice".

There is absolutely nothing wrong with using an ID for a CSS selector when done appropriately.

And actually all the reasons given in the article are all reasons FOR using them.

I do also heavily support the use of classes as much as possible and I personally use an ID so high in the DOM as to be able to override highly specific, often chained class selectors, simply with an ID.

The fact that an ID gets automatically created as properties on the DOM is yet another reason to use them, when applicable.

I'm all for not using IDs as selectors if thats your personal preference, let's just not discourage using them at all as a general best practice because, well, it's not some best practice not to use them.

I'd also recommend not discouraging others to not use a tool just because you have not yet explored all uses for them. How about an unbiased article about how and when they ARE useful?

For instance, I'd prefer there be an ID on each header of this page, should I link it and want a user to jump directly to that portion of the page, like it was designed to do.

Just my two cents.

Code of Conduct Report abuse