Inverted Triangle CSS
ITCSS is a way to structure your CSS projects to minimize specificty issues and organizational problems. ITCSS is not a naming convention.
ITCSS is most effective when used with a preprocessor like Sass, Less, etc.
The inverted triangle refers to how your CSS project should be put together. At the beginning, we have the most far-reaching, least specific, and most generic styles possible. This includes variables, sitewide styles like font-settings, and CSS resets. As we go farther in the file, we get more localized, more specific, and more explicit styles. This includes component-specific styles and rules.
The inverted triangle has layers from top to bottom, representing the amount of reach each layer should have; the first layers have the most, decreasing their reach the farther down you go.
The first two layers should not generate any CSS on their own if being used with a preprocessor.
- Settings - Variables
- Tools - Any mixins or functions that need to be globally available. If they don''t need to be globally available, they should go somewhere else.
- Generic - Includes Normalize, resets, box-sizing rules, etc.
- Elements - These are the styles that refer to unclassed HTML elements. Changing the font-size of headings, the focus styles on inputs, or default anchor and link behavior.
- Objects - Undecorated design patterns, like wrappers, containers, rows, grids, etc.
- Components - Specific UI components. Most of our styling should go here, as most UI components should be composed of objects and components.
- Utilities (Trumps) - Anything that should be able to override the previous styles.
This framework can be combined with BEM to make the HTML more readable for the developer. Using the standard Block, Element (
__), Modifier (
--) syntax, we can also use prefixes and suffixes to make their functionality more clear.
_- Outright hacks
@- Responsive media or print queries (need to escape @ in CSS with
Last modified: 202107020524