Trying to tidy up my CSS, it's a mess, I have a number of IDs spread throughout the divs, child divs so that I am able to select them in CSS.
I was wondering what the correct way of doing this ?
I thought about using classes, which appears to be a better way but still adding a class on every single div seems overkill - maybe using BEMS, good practice to scatter css classes on every element that i need to style ?
Then I thought about using direct child selectors and nth-child selectors, this would tidy things up but then the design is brittle as moving around the DIVS inside the html would break the css.
Can anyone suggest the best way of doing this.
Here's an example, using classes, they had IDs before, so it's better but I am not convinced about the semantics and re-usability. Any improvements that I could make would be really helpful. It is supposed to represent a card with two buttons along the bottom.
<div class="card">
<div class="card-image"></div>
<h2 class="title">My test card</h2><span class="subtitle">by authors name</span>
<p class="card-text">Great info available at this location...................</p>
<div class="button-container">
<button class="share-button">Share</button>
<button class="like-button">like</button>
</div>
</div>