3 ms·
That might make sense in your case but, honestly, it runs entirely counter to the reason CSS exists. A big motivation for the development of CSS was to get awa
by bartread 9y ago
That might make sense in your case but, honestly, it runs entirely counter to the reason CSS exists.
A big motivation for the development of CSS was to get away from the situation in the 90s where elements would have their own styling - complete with duplication - embedded in them using (sometimes non-standard) attributes.
The situation back then made it a nightmare to apply a consistent style across a site, as well as bloating pages at a time when most people accessing the internet at home were doing so using a modem.
Most people don't use modems any more, but many of them do use mobile devices, often with high latency connections depending upon network coverage and contention. In other words unnecessary bloat is still a problem, and that original motivation for CSS is still valid.
- Kiro 9y agoI disagree. I don't care what the motivation was since I believe CSS with cascading styles and global declarations was a failure to begin with. I've built many sites using both traditional CSS, with standards like BEM and now CSS-in-JS and this is the first time it actually makes sense. I have yet to encounter a case where I miss the old way of writing CSS. I think applying "consistent styles" is a fallacy. It sounds like something you want but in the end it becomes a nightmare to maintain once you start sharing styles all across your app. What happens is that you overwrite stuff instead of rewriting because you don't know what rewriting a certain style declaration will affect. My main point however is that there are very few styles that actually make sense sharing between components. I gave one example; colors, but what else? Take stuff like padding and margin for example. It feels like they are something you want to be standardized but usually in big projects they become extremely context dependent and as soon as you need to deviate from the standard it becomes a headache. The bloat argument is invalid if you use a proper CSS-in-JS lib which compiles the styles to CSS classes.