Whenever I see nested CSS, I always think the non-nested version is cleaner.
Then again, I'm lucky enough to often work with my own 'hand-crafted', semantic html, and not some div soup generated by a tool.
Then again, I'm lucky enough to often work with my own 'hand-crafted', semantic html, and not some div soup generated by a tool.
.page form
border: 2px solid #223;
border-radius: 0.15rem;
& button {
background-color: red;
transition: background-color 0.15s ease;
}
&:hover button {
background-color: blue;
}
}
seems way cleaner, easier to read, and more maintainable than the alternative which I don't even wanna type outI really like the look of nested selectors for this reason - because I can group my selectors by component.
.page form {
border: 2px solid #223;
border-radius: 0.15rem;
}
.page form button {
background-color: red;
transition: background-color 0.15s ease;
}
.page form:hover button {
background-color: blue;
}Imagine those three rules in a 200 line CSS file.
E: or would you have to use `>` somehow?