DEV Community

loading...

Discussion on: CSS Best Practices and Advice for beginners

joelbonetr profile image
JoelBonetR Author

Of course, because the practices you are referring to (using ids) are good for:

  • Maintainability
  • Readability
  • Scalability
  • Javascript usage (using vanilla script for adding events is much more efficient when looking for a scoped DOM subtree than searching for classnames, and of course, when js find an ID stop looking if another element have another id because id are unique, which does not happen with classes; even searching a class as child of an id is much more efficient).

And don't cause negative effects on:

  • Speed (loading time, time to first interaction and so).
  • Weight (will stay the same using an id or a classname).
  • DOM size (also will stay the same, an id does no generate any additional DOM element).

If you can't explain something easy and with few words, you may not know enough about that.

Thread Thread
Sloan, the sloth mascot
Comment deleted
Sloan, the sloth mascot
Comment deleted
perpetual_education profile image
perpetual . education

We've decided that this thread of conversation does nothing positive for anyone - and will be removing ourselves from it. We suggest that you do the same, Joel. BTW nice 100/100/100/100 on your site score! That's awesome! See you around.

Thread Thread
joelbonetr profile image
JoelBonetR Author

It could be nice to keep the conversation because it would be nice for readers, now theres plenty of clarifications that I spent time on without context but whatever... it's your decision.

Thread Thread
perpetual_education profile image
perpetual . education

You can add them to your article. They'll still be good time spent. : )