Stop using inline CSS (praise utility classes!)

jacobmparis

Jacob Paris

Posted on May 4, 2019

Stop using inline CSS (praise utility classes!)

You've heard it all before — code-style evangelists preaching from the heavens about Separation of Concerns and Clean Code. It's often hard to argue with them. HTML is for layout, and CSS for styling. Well, mostly, anyway. So we've collectively decided as a species to stop writing code like this:

<p style="font-weight: bold; text-align: right;" />
Enter fullscreen mode Exit fullscreen mode

and this

<div style="display: flex; padding: 1rem; margin: 1rem;" />
Enter fullscreen mode Exit fullscreen mode

and this

<img style="border-radius: 50%;" src="cat.gif" />
Enter fullscreen mode Exit fullscreen mode

And instead moved to the totally different UTILITY CLASSES so our code can look like this!

<p class="font-weight-bold text-right" />
Enter fullscreen mode Exit fullscreen mode

and this

<div class="d-flex p-1 m-1" />
Enter fullscreen mode Exit fullscreen mode

and this

<img class="img-rounded" src="cat.gif" />
Enter fullscreen mode Exit fullscreen mode

I would like to personally thank each and every one of you for your efforts in cleaning up the web and ensuring HTML and CSS never mingle again

💖 💪 🙅 🚩
jacobmparis
Jacob Paris

Posted on May 4, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related