Re: [selectors4] Should the reference combinator really be a combinator?

L. David Baron (2012-03-09 00:34):
> On Wednesday 2012-03-07 14:57 -0800, fantasai wrote:
>> 
>> Hixie's original proposal for :column() used // as a combinator instead. Using a combinator there does avoid the branching possibilities present with :column(), and might therefore make more sense.
> I prefer :column() as it is, and would rather see the reference combinator use a functional pseudo-class (…).  

Maybe pseudo-attributes are more useful than pseudo-classes (and combinators) here.

  td[:col=1]    {font-weight: bold;}
  td[:col=2]    {font-style: italic;}
  td[:col=3]    {font-variant: small-caps;}
  td[:col#=foo] {background: lime;}         /* or =# */
  td[:col.=bar] {background: green;}        /* or =. */
  col#foo       {background: red;}
  col.bar       {background: maroon;}

  <table>
    <caption>3*3 table with 4 cells only</caption>
    <col id=foo><col span=2 class=bar>
    <tr>
      <td rowspan=2>
        td[:col=1][:row=1], td[:col=1][:row=2],
        td[:col#=foo][:row=1], td[:col#=foo][:row=2]
      <td colspan=2>
        td[:col=2][:row=1], td[:col=3][:row=1],
        td[:col.=bar][:row=1], td[:col.=bar][:row=1]
    </tr>
    <tr>
      <td colspan=2 rowspan=2>
        td[:col=2][:row=2], td[:col=3][:row=2],
        td[:col=2][:row=3], td[:col=3][:row=3],
        td[:col.=bar][:row=2], td[:col.=bar][:row=3]
    </tr>
    <tr>
      <td>
        td[:col=1][:row=3], td[:col=1][:row=-1],
        td[:col#=foo][:row=3]
    </tr>
  </table>

You can do most of the common things that ‘:column()’, ‘:nth-column()’ and ‘:nth-last-column()’ can do, except for advanced stuff like “:column(colgroup[span]>col:only-of-type)”.

Note that “:nth-column(1)” ≈ “:column(col:first-of-type)” and “:nth-last-column(1)” ≈ “:column(col:last-of-type)”.

Received on Tuesday, 13 March 2012 00:10:53 UTC