Typically, when nesting CSS, one would utilize .scss
or .sass
along with a compiler tool to generate standard .css
files. However, since December 2023, this feature has been natively supported across the latest browser versions.
Browser support:
- Chrome
>= 120
- Edge
>= 120
- Firefox
>= 117
- Safari
>= 17.2
It’s perfectly acceptable to write CSS in this manner without the need for a compiler tool, as modern browsers can interpret it seamlessly.
Learn more about nesting selectors here.
Discover other useful CSS snippets for 2024 in this post.
It covers:
:has()
subgrid
nesting
text-wrap: balance
text-wrap: pretty
cqw