Improving HTML Legibility When Using Multiple CSS Classes
Published on
One of my primary goals when writing code is to make it easy to understand and quick to scan. Sometimes, using multiple CSS classes on an HTML element can make it harder to read.
To improve legibility, I’ve been experimenting with separating different types of classes using a forward slash where it makes sense. Here’s an example:
<div class="Card">
<span class="Card-icon / Icon Icon--close"></span>
...
</div>
This small addition keeps the code neat and easier to scan at a glance.