top | item 40985126

(no title)

emmacharp | 1 year ago

Some thoughts on reasons above:

With recent display roles (like grid, flex, contents, etc.) the HTML needed exclusively for layout problems is really minimized if not completely nonexistent.

With `:has()` you can query "up" and "previous".

Some structure in your HTML is absolutely necessary, yes. But I'm not sure it is a problem. Data, content and states have structure.

Classes and attributes should be used for styling purposes, yes. Namespacing and linting can do most of the heavy work of keeping things tidy.

discuss

order

dgb23|1 year ago

> With recent display roles (like grid, flex, contents, etc.) the HTML needed exclusively for layout problems is really minimized if not completely nonexistent.

I'm not talking strictly about _problems_ but about requirements/relationships. Flex/grid describe parent/child relationships between elements. They inherently couple styling with structure, so that you are sometimes forced to introduce tags for stylistic grouping.

> With `:has()` you can query "up" and "previous".

:has() is a lookahead.

Please correct me if I'm mistaken: But there are no selector rules that you can put on an element which looks up or at previous siblings that I know of.

The only CSS features that query up/previous are @media and @container rules.

emmacharp|1 year ago

You may have to group elements, yes. But generally speaking, they already are grouped in some logical sense. And you can do a lot now with grid, without having to wrap child elements in containers. It's not absolutely separated but to great degree it is (in my experience at the very least).

And yes, you can select previous elements with :has(). Here is an article about it: https://tobiasahlin.com/blog/previous-sibling-css-has/