HTML - It Doesn’t Matter Which Order You List Your Class Attributes

July 14, 2019 · 1 min

This is a revelation myself and a few members of my team experienced during our most recent interview. I’ll present the candidate with some truly horrific HTML / CSS and I’ll ask them what they would do to improve it. This can include anything from improperly reusing IDs to CSS that isn’t rendering properly.

At one point, the candidate contemplated whether or not changing the order of CSS classes in the HTML element would make a difference. After switching them, the output remained the same.

The only order that matters when it comes to CSS is the order with which the rules are listed on your actual CSS file.


Profile picture

Written by Chris Bridges - living in Austin, writing on the internet. Email·Twitter