W3C home > Mailing lists > Public > www-style@w3.org > March 2018

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

From: <zjz@zjz.name>
Date: Mon, 05 Mar 2018 21:40:31 -0700
Message-Id: <20180305214031.d283c66b19e4487af443a38249fea558.6ddda76032.wbe@email03.godaddy.com>
To: www-style@w3.org
Sorry, the original post made some mistakes, in especial, I meant
pseudo-element selectors, not pseudo-class selectors. So please ignore
the original post, here is the edited proposals:

The expressions in this Email are not in a rigour language so I hope you
don't mind it.

The two proposals are:

1. Introduce a new pseudo element ::between. 2. Allow ::between,
::before and ::after selectors to be recursive.

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

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

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

Let me take the following document as an example:

Example 2
<parent>
  <child1>...</child1>
  <child2>...</child2>
  <child3>...</child3>
</parent>

::before, ::after and ::between of the <parent> element act like this:

<parent>
  <::before>
  </::before>
  <::between>
    <child1>...</child1>
    <child2>...</child2>
    <child3>...</child3>
  </::between>
  <::after>
  </::after>
</parent>

Unlike ::before and ::after which require |content|, the |content|
property is disregarded in ::between.

But that's not even enough, what if we encouter a worse situation
requiring more than one non-semantical layers? Consider the Example 3:

Example 3
<article>
  <div> <!-- non-semantical, for stylistic purpose -->
    <div> <!-- non-semantical, for stylistic purpose -->
      <section>
        ...
      </section>
      <section>
        ...
      </section>
      <section>
        ...
      </section>
    </div>
  </div>
</article>

We can only avoid one such layer by using ::between, since a
pesudo-element selector is not premitted to be recursively applied to
another pesudo element by the current standard, so I propose to allow
::before, ::after and ::between selectors to be recursive. So we can use
::between::between to avoid both the two non-semantical layers, and
actually, any amout of such layers. And also, we can use
::before::before, ::after::after, ::between::before, ::before::between,
etc.

With ::between and recursive ::before, ::after and ::between, we are
able to wipe out almost all kinds of non-semantical code in HTML code,
and finally make it history.

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

Zhang Junzhi
Received on Tuesday, 6 March 2018 04:41:30 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:10 UTC