From the course: CSS: Refactoring Style Sheets

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Rational CSS structure

Rational CSS structure - CSS Tutorial

From the course: CSS: Refactoring Style Sheets

Start my 1-month free trial

Rational CSS structure

- [Teacher] When it comes to refactoring CSS one of the first and most immediately impactful things you'll do is impulse rational CSS structure. Now exactly what rational means in this context can be discussed. What I mean here is ordering rules and properties in a consistent manner that meets the logic of both humans and computers. As already mentioned, respecting and taking advantage of the cascade is a key element to CSS refactoring. Using cascade effectively results in less code and more efficient code, and that code is easier to read. If we start at the top of a style sheet and work our way down, the structure should, in my opinion, and yes you are allowed to disagree and do something else, but in my opinion it should look something like this. We start off with normalization or a CSS reset if that is required. Then move on to global styles. That would be global variables, elements, defaults, colors and such. Then general styles including layouts, the overall areas of the layout…

Contents