HTML Classes: Separation of Concerns
Understand how to use separate HTML classes for styling and JavaScript functionality to maintain clean code. Learn why avoiding duplicate IDs matters and how tools like Webpack and SASS improve large project management.
We'll cover the following...
We'll cover the following...
Recall the button
<button class="btn-large js-hello">Greet</button>
You can see two classes in there, btn-large and js-hello. The first class is used solely for styling, and the second class is used solely for referencing in JavaScript.
It is always preferred to separate classes for styling and functionality. When multiple people work on the same codebase, this separation pays off. This way, a person responsible for styling can add, delete, or rename any styling classes without affecting ...