Mar 31, 2026
The most significant changes in web development don't often come as a big surprise. While technological advancements like streaming video and complex online apps make headlines, the technical foundations of website development can also bring about equally significant improvements. For a long time, developers have had to put up with some tedium whenever they want to use CSS, the styling language that shapes how things look in browsers.
This strategy has changed as a result of the recent widespread adoption of CSS nesting, which has altered how programmers convert design into code. Developers can now organize formatting rules in grouped, layered patterns instead of keeping flat, disjointed style declarations. This organizational change produces something that seems like a blueprint: looking at nested code shows how interface elements relate to one another both geographically and functionally, rather than merely separate style commands.
Modern CSS Nesting
.nav-card {
background: white;
padding: 20px;
& .card-title {
font-size: 1.5rem;
color: #333;
}
}
Although native CSS nesting is a nice improvement, it comes with problems when misused. Developers have historically used pre-processors like SCSS for nesting, which has resulted in intricate relationships between styles and webpage structure. Over-nesting creates a "pyramid of doom," making it difficult to manage code that extends horizontally across the screen.
The "Pyramid of Doom" in SCSS
.header {
.nav {
.menu-list {
.menu-item {
.menu-link {
span {
color: blue; /* Too deep! Who is this span? */
}
}
}
}
}
}
When you need to scroll through five levels of indentation to figure out why a link is “blue”, then the technology has not fulfilled its fundamental purpose: making things clear. Making CSS reflect the parent-child relationships in HTML results in high specificity, which means the styles are so difficult to override and specific that they are nearly impossible to modify afterwards. Consider the situation when one tries to paint the room but realizes that the former owner used a permanent industrial coating that cannot be wiped off with the new one. Deep nesting locks you into decisions you made on day one, making the simple act of changing a hover color an exercise of frustration.
This struggle is particularly painful in large-scale projects. You find yourself scrolling up and down, trying to remember which parent selector you are currently inside. This back-and-forth slows you down. The human brain is not good at keeping track of many things at once. We do better when we have simple pieces of information to work with. When the code gets too complicated to read, we stop being the people who design things and start being the people who clean up the mess. We spend all our time fixing the problems that we made.
To address this, we must adopt a philosophy of "flattening" our logic. The idea should be to describe what an element is, rather than showing the computer where it lives. Instead of nesting a link within a list, a menu, or a navigation, we can just specify a descriptive class for it.
Flat and Robust Approach
.main-nav-link {
color: #555;
text-decoration: none;
&:hover {
color: #007bff;
}
}
If you are looking to refactor your current code, start by identifying the "roots": those core elements that provide the foundation of a component, pull them out of the depths, and give them their own primary identity. Look for the "tipping point" where nesting stops being helpful; usually, it's beyond two or three levels deep. By using a system like BEM (Block, Element, Modifier), you can create unique, descriptive class names that allow elements to stand firmly on their own.
BEM + Shallow Nesting
.user-profile { /* Block */ }
.user-profile__avatar { /* Element */ }
.user-profile--featured { /* Modifier */ }
Easy-to-read stylesheets reduce the time developers must spend figuring out what's going on, resulting in fewer errors and better-looking output. In the end, the best code isn't the cleverest; it’s the code that speaks clearly.
Wrapping Up
At Oshyn, we've observed this scenario so many times to understand what's really happening beneath the surface. Code is not simply a set of instructions that explain to an application how to work or a browser what to render. It's a conversation that spans time and people. When you write code, you're interacting with more than just a machine; you're talking to your future self, the colleague who will eventually join the team in six months, the agency partner who needs to understand your system, and, in the end, the company itself that relies upon this digital foundation to guarantee customer service.
Because of this, we have based our entire strategy on the idea that clarity is the highest level of sophistication, a concept that may seem straightforward but has a profound impact on everything.
Related Insights
-
BLOG
Fernando Torres
The Silent Killer of Performance
Why We Need to Stop Underestimating CSS
-
BLOG
Fernando Torres
Why Accessibility Isn’t Just a Lighthouse Score (and How to Get It Right)
-
BLOG
Fernando Torres
Stop Guessing, Start Testing
Why Enterprises Need to Introduce Front-End Testing to Improve the User Experience
-
BLOG
Fernando Torres
How Fonts Impact Web Performance
Understanding and Optimizing Your Browser's Font Dance