<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Eduardo de la Cruz Palacios</title>
    <description>The latest articles on DEV Community by Eduardo de la Cruz Palacios (@eduardocruzpalacios).</description>
    <link>https://dev.to/eduardocruzpalacios</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3910210%2F481f6f8c-843b-4b6a-9514-924b64bca7ef.png</url>
      <title>DEV Community: Eduardo de la Cruz Palacios</title>
      <link>https://dev.to/eduardocruzpalacios</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/eduardocruzpalacios"/>
    <language>en</language>
    <item>
      <title>CSS Architecture</title>
      <dc:creator>Eduardo de la Cruz Palacios</dc:creator>
      <pubDate>Mon, 04 May 2026 20:37:05 +0000</pubDate>
      <link>https://dev.to/eduardocruzpalacios/css-architecture-4kob</link>
      <guid>https://dev.to/eduardocruzpalacios/css-architecture-4kob</guid>
      <description>&lt;p&gt;Have you ever opened a large codebase and wondered why changing one color broke styles in five unrelated places? Or why two buttons that look identical are defined in completely different ways across the project?&lt;/p&gt;

&lt;p&gt;These are symptoms of the same root problem: no clear separation between layers of concern in the CSS. CSS Architecture exists precisely to solve this.&lt;/p&gt;

&lt;p&gt;Have you noticed that popular libraries like Tailwind or Bootstrap follow recognizable naming patterns such as &lt;code&gt;btn&lt;/code&gt;, &lt;code&gt;btn--disabled&lt;/code&gt;, and &lt;code&gt;color-primary&lt;/code&gt;? That's not coincidence. Those patterns reflect an underlying architectural model, i.e., a shared set of conventions that brings structure to the way styles are written, organized, and scaled across a project.&lt;/p&gt;

&lt;p&gt;This post breaks down what CSS Architecture is, why it matters, and how to apply it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Definition and purpose
&lt;/h2&gt;

&lt;p&gt;CSS Architecture is a set of conventions, principles, and patterns that bring structure to the way styles are written, organized, and scaled across a project. Rather than leaving each developer to make ad-hoc decisions, it establishes a shared language that the whole team follows.&lt;/p&gt;

&lt;p&gt;This structured approach enables teams to develop more efficiently, reduce regressions, and deliver consistent interfaces that scale with the product over time.&lt;/p&gt;

&lt;p&gt;To understand why, let's break it down into its benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability, maintenance​ &amp;amp; reusability&lt;/strong&gt;: The codebase should grow without collapsing. Adding a new component shouldn't require rewriting global styles or introduce visual regressions elsewhere. Define once, use everywhere to avoid reinventing the wheel and copy-pasting styles that drift out of sync. Also, the time to learn the codebase, make changes and debug visual regressions is reduced.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collaboration &amp;amp; onboarding speed&lt;/strong&gt;: When conventions are explicit (naming, file structure), multiple developers can work in parallel without stepping on each other. Reviews are faster and merge conflicts are fewer. When styles are predictable, new developers can jump in more quickly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;UX &amp;amp; theming&lt;/strong&gt;: Users experience a coherent product with the same spacing, typography, and color signals throughout every screen and flow. Furthermore, a well-architected system makes dark mode, white-labeling, or brand refreshes a token swap instead of a full rewrite. If colors and spacing are hardcoded everywhere, a rebrand becomes a nightmare.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In summary, &lt;strong&gt;architecture gives you guardrails as the team and product expand&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Abstraction layers in UI
&lt;/h2&gt;

&lt;p&gt;Well-architected UI systems split styles into distinct, purposeful layers. Each layer answers exactly one question, and never answers another layer's question.&lt;/p&gt;

&lt;p&gt;These are examples of abstraction layers you will find across libraries and design systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tokens&lt;/strong&gt;: The raw design values of the system such as colors, spacing, border radius, or shadows. Everything else references these. Changing a token propagates everywhere automatically.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Themes&lt;/strong&gt;: Token overrides scoped to a context, such as dark mode, brand variants, high-contrast accessibility mode, or white-label products. Themes swap values; they don't rewrite component logic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Layout&lt;/strong&gt;​: How children are distributed inside a parent: grids, flexbox, spacing between siblings, or page regions like main and header. Layout classes are agnostic of visual design, so they must not carry colors, borders, or shadows.​&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Components​&lt;/strong&gt;: The visual identity of a UI piece such as a button, card, badge, or input. Components own their own appearance (color, border, typography) but are completely unaware of where they sit on the page. It means a component must render correctly regardless of its parent, which is achieved by not including positional styles inside a component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;States&lt;/strong&gt;: Variations of a component triggered by user interactions or system context, such as hover, focus, active, disabled, loading, error, or selected. States modify a component without replacing it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Utilities&lt;/strong&gt;: Single-purpose helper classes for one-off adjustments that don't belong in a component, e.g., cursor-pointer and border-0.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Methodologies to implement CSS Architecture
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Object-Oriented CSS (OOCSS)​
&lt;/h3&gt;

&lt;p&gt;OOCSS focuses on building flexible and reusable components where each class does one thing well. Coined by Nicole Sullivan, it borrows the principles of object-oriented programming and applies them to CSS: identify repeating visual patterns, abstract them into reusable objects, and compose them freely across the UI.&lt;/p&gt;

&lt;p&gt;It is the mindset and/or method of separating:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Containers and content&lt;/strong&gt;: a component should not know where it lives. Avoid location-specific styles that tie appearance to a position in the DOM, such as nested selectors like .&lt;code&gt;page .content h3 {}&lt;/code&gt;. If a heading needs a style, that style belongs on the heading itself instead of its ancestors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structural and visual styling&lt;/strong&gt;: keep layout concerns like padding, margin, and display separate from visual ones like colors, fonts, and borders. This way, the same structure can wear different skins, and the same skin can be applied to different structures.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tradeoffs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More maintainability: reducing or eliminating duplication in CSS means fewer places to update when a design decision changes.&lt;/li&gt;
&lt;li&gt;More classes per element: composing styles from multiple single-purpose classes means HTML elements tend to carry more class names, which can feel verbose and harder to read at a glance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* BAD */&lt;/span&gt;

&lt;span class="nc"&gt;.page-about&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grey&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.page-contact&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* BETTER

&amp;lt;section class="page page-contact"&amp;gt;...&amp;lt;/section&amp;gt;

*/&lt;/span&gt;

&lt;span class="nc"&gt;.page&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.page-about&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grey&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.page-contact&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example 2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* BAD */&lt;/span&gt;

&lt;span class="nt"&gt;article&lt;/span&gt;&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;column-gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#111&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.25rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt; &lt;span class="m"&gt;12px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;right&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* BETTER

&amp;lt;article class="card-container bgc-primary"&amp;gt;

    &amp;lt;div class="card"&amp;gt;
        &amp;lt;p class="card-content text-primary"&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;

&amp;lt;/article&amp;gt;

*/&lt;/span&gt;

&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--fontSizeL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.75rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--fontSizeM&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.25rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;column-gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.bgc-primary&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt; &lt;span class="m"&gt;12px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card-content&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--fontSizeM&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;right&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.text-primary&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#111&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Learning resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://es.slideshare.net/slideshow/object-oriented-css/990405" rel="noopener noreferrer"&gt;https://es.slideshare.net/slideshow/object-oriented-css/990405&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.keycdn.com/blog/oocss" rel="noopener noreferrer"&gt;https://www.keycdn.com/blog/oocss&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Atomic / Functional CSS (ACSS)​
&lt;/h3&gt;

&lt;p&gt;ACSS focuses on &lt;strong&gt;creating the smallest possible single-purpose utility classes and applying them directly in the HTML&lt;/strong&gt;. Rather than writing semantic component classes that bundle multiple declarations together, each class maps to exactly one CSS rule.&lt;/p&gt;

&lt;p&gt;The name comes from the idea of atoms: the smallest indivisible unit of style.&lt;/p&gt;

&lt;p&gt;Tradeoffs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Classes are immutable: an atomic class always does the same thing regardless of context, making the CSS highly predictable. &lt;code&gt;.mt-16&lt;/code&gt; will always apply a 16px top margin. It will never be overridden by another rule or behave differently depending on where it is used.&lt;/li&gt;
&lt;li&gt;Reusable across projects: because atomic classes carry no semantic meaning tied to a specific UI or domain, the same utility layer can be dropped into entirely different projects without modification.&lt;/li&gt;
&lt;li&gt;Easier to debug: since styles live directly in the HTML as class names, you can inspect an element and immediately understand what is being applied without jumping between files or hunting through cascading rules.&lt;/li&gt;
&lt;li&gt;Verbose upfront: the initial cost is high, as there are many classes to define before the system pays off, and HTML markup can become dense with long chains of class names on a single element.&lt;/li&gt;
&lt;li&gt;Watch out with absolute values: atomic classes that encode fixed values like &lt;code&gt;w-320&lt;/code&gt; or &lt;code&gt;text-14&lt;/code&gt; can cause problems across devices and screen sizes. Prefer classes built on a relative scale or design tokens to keep the system adaptable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.bg-blue&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.bg-yellow&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;yellow&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.text-2rem&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.padding-0&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.padding-1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/*

&amp;lt;article class="bg-blue padding-1"&amp;gt;
    &amp;lt;p class="text-2rem"&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;/article&amp;gt;

*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Learning resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/lets-define-exactly-atomic-css/" rel="noopener noreferrer"&gt;https://css-tricks.com/lets-define-exactly-atomic-css/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Block Element Modifier (BEM)​
&lt;/h3&gt;

&lt;p&gt;BEM is a naming convention for CSS classes that brings clarity and predictability to how styles are structured and related. Rather than relying on the cascade or nesting to express relationships between parts of a UI, BEM makes those relationships explicit in the class name itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Block is a standalone component, an Element is a part that belongs to a block and has no meaning outside of it, and a Modifier is a variation of a block or element&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Tradeoffs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More control over specificity: because BEM styles are almost entirely class-based and flat, there is little or no nesting in the CSS. This keeps specificity low and uniform across the codebase, which means fewer unexpected overrides and side effects when styles are added or changed.&lt;/li&gt;
&lt;li&gt;Blocks must remain independent: a block should never override the styles of another block or its modifiers. When it does, specificity is no longer controlled and the predictability that BEM provides starts to break down. Each block is responsible for itself and nothing else.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Syntax:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modifiers apply to both blocks and elements like &lt;code&gt;block--modifier&lt;/code&gt; and &lt;code&gt;block__element--modifier&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Naming must be meaningful and non-descriptive of appearance. If a class name describes how something looks rather than what it is, renaming it becomes necessary every time the visual design changes, so it forces updates to both the selector and the styles. &lt;code&gt;blog-post__title&lt;/code&gt; and &lt;code&gt;button--primary&lt;/code&gt; are correct. &lt;code&gt;yellow-title&lt;/code&gt; is wrong.&lt;/li&gt;
&lt;li&gt;Elements should be written as direct children of their block, never nested beyond one level. Deep nesting creates class names that are tightly coupled to a specific DOM structure, making them fragile and hard to reuse. &lt;code&gt;photo__caption&lt;/code&gt; and &lt;code&gt;photo__text&lt;/code&gt; are correct. &lt;code&gt;photo__caption__text&lt;/code&gt; is wrong.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.social&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.social--vertical&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.social__link&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.social__image&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;24px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;24px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.social__image--network1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.social__image--network2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/*

&amp;lt;section class="social social--vertical"&amp;gt;

    &amp;lt;a href="#" class="social__link"&amp;gt;
        &amp;lt;img src="fb.svg" class="social__image social__image--network1"&amp;gt;
    &amp;lt;/a&amp;gt;

    &amp;lt;a href="#" class="social__link"&amp;gt;
        &amp;lt;img src="tw.svg" class="social__image social__image--network2"&amp;gt;
    &amp;lt;/a&amp;gt;

&amp;lt;/section&amp;gt;

*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Learning resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/bem-101/" rel="noopener noreferrer"&gt;https://css-tricks.com/bem-101/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://philipwalton.com/articles/side-effects-in-css" rel="noopener noreferrer"&gt;https://philipwalton.com/articles/side-effects-in-css&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://bem-cheat-sheet.9elements.com/" rel="noopener noreferrer"&gt;https://bem-cheat-sheet.9elements.com/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Inverted Triangle CSS (ITCSS)​
&lt;/h3&gt;

&lt;p&gt;ITCSS organizes CSS into a set of ordered layers, each with a clear role and a defined level of specificity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyj6hon1x2nonrvxrnvqy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyj6hon1x2nonrvxrnvqy.png" alt=" " width="761" height="475"&gt;&lt;/a&gt;&lt;br&gt;
Source: &lt;a href="https://www.wpdesk.pl/blog/struktura-itcss-czyli-jak-zapanowac-nad-plikami-css/" rel="noopener noreferrer"&gt;https://www.wpdesk.pl/blog/struktura-itcss-czyli-jak-zapanowac-nad-plikami-css/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each layer is explained in detail below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Settings&lt;/strong&gt;: variables used by other layers​.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tools&lt;/strong&gt;: functions and mixins used by other layers​.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generic&lt;/strong&gt;: reset or normalize browsers’ base styles​.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Elements&lt;/strong&gt;: rules affecting HTML tags.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Objects&lt;/strong&gt;: generic classes that are reusable throughout the project, such as &lt;code&gt;.container​&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Components&lt;/strong&gt;: specific parts of the interface, such as the main navigation bar. Styles here will only affect that component​.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trumps / Utilities&lt;/strong&gt;: rules that override any other rules defined in the previous layers. It is the only layer where &lt;code&gt;!important&lt;/code&gt; is allowed. For instance, a selector for a class &lt;code&gt;.hidden&lt;/code&gt; with &lt;code&gt;display: none&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The inverted triangle metaphor is intentional: the widest, most generic styles sit at the top and affect the broadest scope, while the narrowest, most specific styles sit at the bottom and affect the smallest scope. Rules flow in one direction from low specificity to high, which prevents the specificity conflicts and accidental overrides that result in unstructured codebases.&lt;/p&gt;

&lt;p&gt;Tradeoffs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Specificity is always intentional: as each layer has a defined place in the order, styles never fight each other by accident. It reduces the amount of side effects.&lt;/li&gt;
&lt;li&gt;Highly compatible with other methodologies: ITCSS is not a naming convention, so it works alongside BEM, OOCSS, or ACSS without conflict. While it provides the folder and layer structure, other methodologies handle the naming within each layer.&lt;/li&gt;
&lt;li&gt;Requires upfront discipline: the system pays off at scale, but it demands that the team agrees on and respects the layer boundaries from the start. Dropping styles into the wrong layer quietly undermines the entire model.&lt;/li&gt;
&lt;li&gt;Though not strictly required, ITCSS strongly encourages the use of a CSS preprocessor such as Sass or Less to increase the productivity of the team​.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example for Sass preprocessor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* Should live in: settings/colors.settings.scss */&lt;/span&gt;

&lt;span class="nv"&gt;$colorPrimary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/* Should live in: tools/mixins/polygons.mixins.tools.scss */&lt;/span&gt;

&lt;span class="k"&gt;@mixin&lt;/span&gt; &lt;span class="nf"&gt;circle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Should live in: generic/reset.generic.scss */&lt;/span&gt;

&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Should live in: elements/text.elements.scss */&lt;/span&gt;

&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;'../settings/colors.settings.scss'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;h3&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$colorPrimary&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Should live in: objects/flex.objects.scss */&lt;/span&gt;

&lt;span class="nc"&gt;.container-flex-vertical&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Should live in: components/icon.components.scss */&lt;/span&gt;

&lt;span class="nc"&gt;.icon&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;24px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;24px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Should live in: trumps/display.trumps.scss */&lt;/span&gt;

&lt;span class="nc"&gt;.display-none&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Learning resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.xfive.co/blog/itcss-scalable-maintainable-css-architecture/" rel="noopener noreferrer"&gt;https://www.xfive.co/blog/itcss-scalable-maintainable-css-architecture/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://speakerdeck.com/dafed/managing-css-projects-with-itcss" rel="noopener noreferrer"&gt;https://speakerdeck.com/dafed/managing-css-projects-with-itcss&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Scalable and Modular Architecture for CSS (SMACSS)​
&lt;/h3&gt;

&lt;p&gt;SMACSS provides a set of abstraction layers built around the following idea: certain CSS properties belong in certain layers and nowhere else.&lt;/p&gt;

&lt;p&gt;Tradeoffs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scalability and maintenance: by enforcing a clear separation between layers, SMACSS prevents styles from bleeding into the wrong context. As the codebase grows, each layer remains predictable and contained, making it significantly easier to locate, change, and extend styles without unintended side effects.&lt;/li&gt;
&lt;li&gt;Though not strictly required, SMACSS strongly encourages the use of a CSS preprocessor such as Sass for productivity's sake. Splitting styles across multiple layers naturally leads to multiple files, and a preprocessor makes importing, organizing, and sharing variables across those files easier to maintain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Abstraction layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Base&lt;/strong&gt;: the default styles for bare HTML elements. Wherever this element appears on the page, it should look like this. No classes or IDs, but only element selectors, resets, and normalize rules. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layout&lt;/strong&gt;: styles that hold one or more modules together and define the major structural regions of a page, such as the header, footer, sidebar, or main content area. Layout is concerned with position and dimension, not visual appearance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Module&lt;/strong&gt;: the reusable, modular parts of the design such as a product card, a navigation menu, or a search form. Modules are self-contained and should work correctly regardless of which layout region they are placed in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State&lt;/strong&gt;: describes how a module looks in a particular condition triggered by user interaction or system context, such as an expanded or collapsed accordion, a success message, or an error input. State styles are always applied on top of a module and override only what needs to change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Theme&lt;/strong&gt;: a consistent set of visual styles applied across layouts and modules to define the overall look and feel of the application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example for Sass preprocessor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* Should live in: base/reset.base.scss */&lt;/span&gt;

&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Should live in: layout/footer.layout.scss */&lt;/span&gt;

&lt;span class="nc"&gt;.footer-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="na"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Should live in: modules/form-login.module.scss */&lt;/span&gt;

&lt;span class="nc"&gt;.form-login&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Should live in: state/dropdown.state.scss */&lt;/span&gt;

&lt;span class="nc"&gt;.dropdown__button-expanded&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.dropdown__button-collapsed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/* Should live in: theme/dark.theme.scss */&lt;/span&gt;

&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;'../base/colors.base.scss'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="nc"&gt;.dark&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$black-color&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$white-color&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="nc"&gt;.white&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$white-color&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$black-color&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Learning resources:​&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://smacss.com/" rel="noopener noreferrer"&gt;http://smacss.com/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  CSS Specificity and CSS Architecture
&lt;/h2&gt;

&lt;p&gt;Specificity is the rule the browser uses to decide which CSS declaration wins when two or more rules target the same element. It is not about order in the file, but about weight. Every selector carries a score, and the declaration with the highest score is the one that gets applied.&lt;/p&gt;

&lt;p&gt;The score is calculated across three tiers. IDs carry the most weight, followed by classes, attributes, and pseudo-classes, and finally element selectors and pseudo-elements. Inline styles sit above all of them, and !important overrides everything.&lt;/p&gt;

&lt;p&gt;A rough way to read it is as three numbers (IDs, classes, elements):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;a&lt;/code&gt; (0, 0, 1 element).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.nav a&lt;/code&gt; (0 IDs, 1 class, 1 element): beats the one above.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;#header .nav a&lt;/code&gt; (1 ID, 1 class, 1 element): beats the two above.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;a style="..."&amp;gt;&lt;/code&gt;: inline, beats all of the above.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;color: red !important&lt;/code&gt;: overrides everything.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The problem arises when specificity grows uncontrolled. A developer adds a rule that does not apply, so they make the selector more specific to force it through. Another developer encounters the same problem and goes one level higher. Over time the codebase accumulates deeply nested selectors and scattered &lt;code&gt;!important&lt;/code&gt; declarations. At that point, the only way to override anything is to keep escalating, which makes the CSS increasingly fragile and unpredictable.&lt;/p&gt;

&lt;p&gt;This is exactly where CSS architecture becomes essential. Methodologies like BEM deliberately keep all styles at the class level without nesting, which means every rule carries the same low specificity score of (0, 1, 0). Then, there are no &lt;del&gt;surprises&lt;/del&gt; side effects. ITCSS takes a structural approach to the same problem: by ordering layers from lowest to highest specificity, it ensures that a utility class at the bottom of the triangle will always override a base element style at the top.&lt;/p&gt;

&lt;p&gt;In short, unmanaged specificity is one of the most common reasons CSS becomes painful to maintain at scale. &lt;strong&gt;CSS Architecture brings specificity under deliberate control&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Learning resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Cascade/Specificity" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Cascade/Specificity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/specifics-on-css-specificity/" rel="noopener noreferrer"&gt;https://css-tricks.com/specifics-on-css-specificity/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Recommendations for various kinds of Frontend projects
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CSS libraries and frameworks
&lt;/h3&gt;

&lt;p&gt;When building a CSS library or framework, the audience is other developers, which means clarity, predictability, and ease of use are non-negotiable. The architecture must be easy to learn, contribute to, and to maintain over time as the library evolves and grows.&lt;/p&gt;

&lt;p&gt;Two concerns are especially important here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maintenance of the library itself: as new components are added and existing ones are updated, the architecture must prevent regressions and keep specificity under control. Styles should never collide with each other, and contributors should always know exactly where a new rule belongs.&lt;/li&gt;
&lt;li&gt;Ease of use for other developers: a library with a predictable naming convention and a clear structure is significantly easier to adopt, extend, and override. Developers consuming the library should be able to look at a class name and immediately understand what it does and where it comes from.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because we rarely know how large a library or framework will grow, it is important to choose an architecture that scales gracefully from the start rather than one that needs to be restructured later:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ITCSS or SMACSS are recommended as the overall organizational structure. Both provide a layered approach that accommodates growth without collapsing under its own complexity, and both keep specificity intentional and ordered.&lt;/li&gt;
&lt;li&gt;BEM is recommended for naming the classes of individual components within those layers. It makes the relationship between a block, its elements, and its modifiers explicit in the class name itself.&lt;/li&gt;
&lt;li&gt;OOCSS: since a library is essentially a collection of reusable objects, the OOCSS mindset of separating structure from visual design fits naturally.&lt;/li&gt;
&lt;li&gt;Utility layer (ACSS): most mature libraries like Bootstrap and Tailwind expose a utility layer alongside their components. Even if the library is not fully atomic, offering a set of single-purpose utility classes gives consumers flexibility for one-off adjustments without overriding component styles directly.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  HTML-CSS-JS projects
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Projects with a limited or small scope
&lt;/h4&gt;

&lt;p&gt;When a project has a clearly defined and limited scope, e.g., a landing page, a promotional site, or a prototype that is not expected to grow significantly, we can afford a lightweight approach. In these cases, BEM alone is a suitable option. It brings enough structure to keep class names meaningful and styles predictable without introducing the overhead of a full layered system. The goal here is clarity and speed, not long-term scalability.&lt;/p&gt;

&lt;h4&gt;
  
  
  Large or long-lived projects
&lt;/h4&gt;

&lt;p&gt;When the project is expected to grow, be maintained over time, or be worked on by multiple developers, a more robust architecture becomes necessary. BEM alone may not be sufficient, as the absence of a clear layer structure makes it increasingly difficult to know where new styles belong and how they relate to existing ones.&lt;/p&gt;

&lt;p&gt;In these cases, the same formula is recommended: ITCSS or SMACSS as the organizational backbone, OOCSS as the guiding mindset when designing components, and BEM for naming classes within them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Web components library​ or design systems
&lt;/h3&gt;

&lt;p&gt;Web components are built around a fundamental philosophy: each component owns its styles entirely. A button, an input, or a modal ships with its own CSS encapsulated inside it, i.e., no styles leak in from the outside, and no styles leak out. This is enforced by the Shadow DOM, which creates a hard boundary between a component's internal styles and the rest of the page.&lt;/p&gt;

&lt;p&gt;This encapsulation changes how architecture is applied, but it does not eliminate the need for it. A few important considerations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Encapsulation does not mean isolation from a system, as components still need to feel cohesive across the library. ITCSS or SMACSS can still provide the organizational backbone at the system level, not for writing styles directly but for managing the design tokens and variables that components consume. This allows the library to remain consistent and themeable without breaking encapsulation.&lt;/li&gt;
&lt;li&gt;CSS custom properties are the bridge. As CSS variables pierce the Shadow DOM boundary, they are the primary mechanism for making components customizable and for applying themes across the entire library. A well-architected token layer that exposes variables like &lt;code&gt;--color-primary&lt;/code&gt; or &lt;code&gt;--spacing-md&lt;/code&gt; gives consumers the ability to skin the whole library by overriding a handful of values, without touching any component internals.&lt;/li&gt;
&lt;li&gt;Exposed attributes for style variants: components can expose HTML attributes or CSS parts that allow consumers to trigger specific styles from the outside. This is the idiomatic way to handle variants and states in a web components context, keeping the API surface clean and intentional.&lt;/li&gt;
&lt;li&gt;BEM for complex components: while simple components like a button or a badge may not need a formal naming convention internally, more complex components such as a date picker, a data table, or a photo gallery can grow significantly in internal complexity. Applying BEM within those components brings the same benefits it does anywhere else: clear relationships between parts, predictable specificity, and easier maintenance as the component evolves.&lt;/li&gt;
&lt;li&gt;Design tokens as the foundation. They are not optional in a design system context. They are the contract between design and development. Defining tokens at the system level and having every component reference them ensures that a single change propagates consistently across the entire library, which is the core promise of a design system.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  JS-framework projects: Angular, Lit, React, etc.
&lt;/h3&gt;

&lt;p&gt;Teams working with component-based frameworks often develop their own internal agreements about how to organize CSS, and those conventions vary significantly from project to project.&lt;/p&gt;

&lt;p&gt;Although teams working with these technologies may organize CSS differently from the approaches seen in this post, the same formula is still recommended:​ ITCSS or SMACSS as the organizational backbone, OOCSS as the guiding mindset when designing components, and BEM for naming classes within them.&lt;/p&gt;

&lt;p&gt;In addition, it is crucial to style at the correct layer of abstraction to avoid CSS side effects. One of the most common pitfalls is solving a layout problem in the wrong place, e.g., adding margin to a product card component in order to fix the spacing in a product list. The component is now making assumptions about its context, which breaks its reusability. Layout concerns belong in the layout layer, and component concerns belong in the component layer. Keeping that boundary clean is what prevents side effects from accumulating over time.&lt;/p&gt;

&lt;p&gt;Another relevant point stems from the fact that frameworks like Angular, React and Lit automatically ensure that the styles you write inside a component only apply to that component. A common misconception is that scoping solves the architecture problem. It does not. Here is why: Scoping answers the question "will my styles affect something outside this component?" The answer is no. But it does not answer "are the styles inside this component well organised, predictable, and easy to maintain?". That is entirely up to the developer. This is why BEM and OOCSS still matter inside scoped styles. The scope handles the boundary with the outside world, but the architecture handles the quality and predictability of what lives inside that boundary. Both are needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final thoughts
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Purpose: caring about CSS reduces side effects and improves maintainability
&lt;/h4&gt;

&lt;p&gt;A deliberate approach to CSS architecture reduces the surface area for side effects, makes styles easier to reason about, and significantly lowers the effort required to change, extend, or debug the UI as the project grows. The methods covered in this post are an investment in the long-term health of the codebase.&lt;/p&gt;

&lt;h4&gt;
  
  
  Flexibility
&lt;/h4&gt;

&lt;p&gt;None of the architectures and methodologies covered here should be applied dogmatically. They are tools, not laws. In practice, the most effective approach is rarely a single methodology applied in its pure form, but a combination tailored to the specific needs of the project and the team.&lt;/p&gt;

&lt;p&gt;This flexibility manifests in several ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Combining methodologies: ITCSS for layer structure, BEM for component CSS classes naming, and OOCSS as the guiding mindset is a common and effective combination, as seen throughout this post.&lt;/li&gt;
&lt;li&gt;Adding abstraction layers: if your project has recurring patterns that do not fit neatly into an existing layer, adding a new one is entirely valid. The goal is clarity, not compliance.&lt;/li&gt;
&lt;li&gt;Removing unnecessary layers (YAGNI): if a layer does not serve a purpose in your project, do not include it. A small project does not need all seven ITCSS layers. Start with what you need and add layers only when the complexity justifies them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Real life decisions are harder than theory
&lt;/h4&gt;

&lt;p&gt;The gap between understanding a methodology and applying it confidently in a real codebase is significant.&lt;/p&gt;

&lt;p&gt;Two questions come up repeatedly in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Separating container from content sounds straightforward until you encounter a project with multiple container types that share some styles but not others, or content that behaves differently depending on where it is placed. The line between the two is rarely as clean in practice as it is in a diagram.&lt;/li&gt;
&lt;li&gt;Deciding what constitutes a block versus an element in BEM puzzles even experienced developers. Given a navigation list, is the list a block and the items its elements, or is each item its own block? There is no single correct answer. Context, team convention, and reusability requirements all factor in. The important thing is to make a deliberate decision and apply it consistently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These ambiguities are not flaws in the methodologies, but a reminder that architecture requires judgment, not just knowledge.&lt;/p&gt;

&lt;h4&gt;
  
  
  Others' solutions do not replace architectural thinking
&lt;/h4&gt;

&lt;p&gt;Modern JS frameworks and libraries offer powerful built-in mechanisms for managing styles. These tools solve real problems and are worth using. However, none of them prevent poorly written CSS. Scoping contains the damage; it does not eliminate it. A scoped component with tangled selectors, uncontrolled specificity, and mixed concerns is still a maintenance problem.&lt;/p&gt;

&lt;p&gt;Regardless of the tools in use, the OOCSS mindset and the principle of dividing styles into deliberate layers of abstraction remain relevant. The framework handles the boundaries; the architecture handles the quality of what lives inside them.&lt;/p&gt;

</description>
      <category>css</category>
      <category>frontend</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
