Re: Column text color

> [Original Message]
> From: Boris Zbarsky <bzbarsky@MIT.EDU>
>
> Sandy Smith wrote:
> > http://ln.hixie.ch/?start=1070385285&count=1
> > 
> > This is a total off-the-top-of-my-head idea but what about building in
a 
> > CSS accessor for the TD element's "header" property? That way as a
table 
> > cell is being evaluated, a property like:
> > 
> > td::header#myColumn { color: red }
> > 
> > ...would take precedence over any definition for a TR element.
>
> How would this work exactly?  That is, how would this be used in an 
> actual document?

The answer depends on whether the querent is referring to the
"headers" or the "scope" attribute on TD in HTML4 and later.

If he is referring to the headers attribute, which is a space separated
list of ID's of cells that contain header information for the cell,
the following bit of CSS2 should do what Sandy wants:
td[headers~=myColumn] {color:red}

However, if he is asking for CSS support for scope and the rest
of the HTML table cell header model, that gets tricky very quickly.

Look at the last example in Section 11.4.1 of HTML 4.01. [1]

If we want CSS to able to handle that example as suggested
for an aural user agent by stating the contents of its header cells
before the content of the cell itself, CSS'll need a way to identify
which other cells are its headers.  This information just simply
is not available in the document tree itself and requires that
user agent have knowledge about the HTML table model,
much as knowledge of the document language is needed
for some of the other features of CSS such as the class
and id selectors or many of the pseudoclass selectors.

Assuming the last cell in the second row of the last example
of that example has added to it the attribute id="Fee",
then I think he asking for something like:

td:header(Fee) {color:red}

to make all three of the cells, £32, £18, and £18 have red text.

or:
@media (aural) {
td:header(Fee)::before {content:"Fee: ")
}

to add the word fee to be spoken before the cell contents.

Making the example work in CSS without adding id
attributes to it would require something like:

@media (aural) {
td:hasheader::before {content: header(row), header(col)}
}

which in intended to insert the content of the row header
and then the column header before the cell when spoken,
regardless of how the header information is specified.

In the case of the HTML table model this info is given
by the scope and headers attributes as well as by the
presence of <th> cells in the same row or column.
The obvious question, is it worth adding the ability to
handle this aspect of the HTML table model in CSS?

Note; I have not determined if any CSS syntax
proposed here conflicts with that used with other
new or proposed features for CSS3, nor do I assert
that I believe that the syntax proposed here is the
best choice to do what is desired.

[1] http://www.w3.org/TR/html401/struct/tables.html#h-11.4.1

Received on Friday, 5 December 2003 15:26:04 UTC