Two proposals: 1. Implement a new pseudo-class selector ::between, 2. Allow pseudo-class selectors to be recursive

Hello, CSS-WG staff:

I would like to propose two ideas on pseudo-class selectors:

Oftentimes, we encounter situations where it's not enough to just use
semantical elements to represent documents, so we have to end up hacking
ugly code like these:

Example 1
<article>
  <div> <!-- for stylistic purpose -->
    <section>
      ...
    </section>
    <section>
      ...
    </section>
    <section>
      ...
    </section>
  </div>
</article>

So I propose to introduce a new pesudo-class ::between. It generates a
node as if it was the child of an element which is between ::before and
::after, and all the actual children of the element act as if they were
"moved down" to become the children of ::between node. When it applies
to the <article> in Example 1, it serves the stylistic purpose as the
<div> does. With ::between, we can largely avoid writing
stylistic-purpose-only code.

But that's not even enough, what if we encouter a worse situation
requiring more then one stylistic-purpose-only layers?

Example 2
<article>
  <div> <!-- for stylistic purpose -->
    <div> <!-- for stylistic purpose -->
      <section>
        ...
      </section>
      <section>
        ...
      </section>
      <section>
        ...
      </section>
    </div>
  </div>
</article>

We can only reduce one such layer by using ::between, a pesudo-class
selector is not premitted to be applied to an pesudo-class-generated
element by the current standard, so I propose to allow pesudo-class
selectors to be recursive. So we can use ::between::between to reduce
these two layers, and actually, any amout of layers.
And also, we can use ::before::before, ::after::after,
::between::before, ::before::between, etc.

With ::between and recursive pesudo-classes, we are able to wipe out
almost all kinds of stylistic code in HTML code, and finally make them
history.

Thank you for your time of reading my post, and I am looking forward to
hearing your opinions on this.

Received on Monday, 5 March 2018 23:31:38 UTC