3 ms·
> I wish for the day where I can really just write clean semantic html and then add the CSS afterwards on top of it. What exactly is stopping you from doing ju
by FrontAid 5y ago
> I wish for the day where I can really just write clean semantic html and then add the CSS afterwards on top of it.
What exactly is stopping you from doing just that today?
- deleted 5y ago[deleted]
- dgb23 5y agoFor certain layouts and CSS features to work you need to add structure for it AKA additional tags, typically divs and spans because they have no meaning in terms of your document. So your document becomes a mix of semantic structure and then wrappers, containers, pushers, purely visual areas and so on. Also you're going to have things that are specifically redundant for your use-case, but you still add them for consistency and re-usability. CSS would have to be quite a bit more powerful to achieve a clean separation of document structure and layout. It would need things like purely visual grouping mechanisms, reactive or backtracking selectors and HTML itself would probably need to be either a relational or graph structure instead of a tree to actually convey the semantics correctly and consistently.
- valenterry 5y agoOne example is to "inherit" class styles. E.g. let's say I have some html like <p class="warning">be very careful<p> and there is some 3rd party CSS that already has nice styling for a warning paragraph. But it uses .warn as a class, not .warning. I don't want to change my HTML and I also don't want to copy the style. I want to tell CSS that my own .warning should inherit the style of .warn (and maybe adjust it slightly if necessary) That is (to my knowledge) currently not possible.
- Semaphor 5y agoOnly semi-relevant, but this is possible with SASS’s @extend: https://sass-lang.com/documentation/at-rules/extend https://sass-lang.com/documentation/at-rules/extend
- moritzwarhier 5y agoBecause the output is still CSS, this would lead to a lengthened (redundant) selector though. Also, AFAIK it would be impossible with a class that is not part of your SCSS tree. If you are able to import the library CSS in to your own SCSS, OK, no problem. But that would introduce unneeded complexity. If using a bundler and one output file, copying the library CSS rules and applying them to your own could maybe even lead to the same output as @extend - a combined selector .warn, warning (you already kind of addressed all of that already in your "semi-relevant" disclaimer)
- Semaphor 5y ago> (you already kind of addressed all of that already in your "semi-relevant" disclaimer) You make some good points, and I wish I could still edit it to "kind of possible" ;)