- From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
- Date: Sat, 02 Jul 2005 16:19:53 +1000
- To: "L. David Baron" <dbaron@dbaron.org>
- CC: www-style@w3.org
L. David Baron wrote: > There are much simpler solutions for the problem of column styling than > a second pass of selector matching. For example, we could have column > selectors that select based on the table semantics of the underlying > content (rather than how that content happens to be displayed). Yes, I fully agree with this idea which is much like what I previously wrote [1]. However, I've been thinking about the limitation of only being able to apply :nth-column to elements which are semantically tabular, as defined by the markup language, rather than any element the author wants treated as struturally/visually tabular. I've been thinking what if there were a way to decleratively describe the structure of the markup (independant of how the document is finally displayed) in a way that lets the UA calculate the columns before layout is done, or, infact, even before the cascade. Here are my first thoughts on how this could possibly be achieved. It is by no means a formal proposal of any kind, just a bit of brainstorming to get the ball rolling. We've already established that's it's not possible to achieve this based on the 'display' property, and therfore using "display: table-*;" as a way to determine an element is a table-cell, for example, for the purpose of calculating which column it fits in is not feasible. So, what we need is a way to unconditionally declare that some element *is* a table, or *is* a table-cell, etc. regardless of how it is eventually rendered. My first idea is to use an @-rule that contains such declarations. For example: (I'll use the HTML table element names for simplicity, but the idea is that it could apply to any elements the author chooses) @table { table: selector(table); table-row-group: selector(table tbody, table thead, table tfoot); table-row: selector(table tr); table-cell: selector(table tr td); table-cell-colspan: attr(colspan); table-cell-rowspan: attr(rowspan); ... } The idea is that the above declares which elements should be considered part of a table structure for the purpose of calculating which table structure related selectors, such as :nth-column() or :nth-row(), apply. Note that this is completely independant of how such elements will be rendered, and doesn't not affect the default 'display' value of the selected elements in anyway. Now that the the UA is able to determine the structure of table markup, and it can determine which elements are table cells and how determine how many rows or columns it spans structurally, it should be possible to calculate things such as which column a cell belongs to, structurally. e.g. <table> <tr> <td colspan="2">r1d1 r1d2</td> <td colspan="2">r1d3 r1d4</td> </tr> <tr> <td>r2d1</td> <td rowspan="2">r2d2 r3d2</td> <td>r2d3</td> <td>r2d4</td> </tr> <tr> <td>r3d1</td> <td>r3d3</td> <td>r3d4</td> </tr> </table> :nth-column/row could be defined to either select only the cells that start in the selected column/row or all cells the span the selected column/row. Perhaps this could be another aspect declared in the @table rule. For the purposes of this, I'll assume they only select the cells that start in the selected column/row. td:nth-column(1) should select cells r1d1, r1d2 and r1d3 td:nth-column(2) should select cell r2d2 td:nth-column(3) should select cells r1d3, r2d3 and r3d3 td:nth-column(4) should select cells r2d4 and r3d4 They should select even if they're not rendered as table cells. i.e. td:nth-column(2) { display: block; } does not cause any circular references, the selector still applies based on the structure of the document, which is declared in the above @-rule. [1] http://www.w3.org/mid/42BFEB1B.2010203@lachy.id.au -- Lachlan Hunt http://lachy.id.au/
Received on Saturday, 2 July 2005 06:20:10 UTC