Class applied to col

Giganews Newsgroups
Subject: Class applied to col
Posted by:  emf (emfr…@gmail.com)
Date: Fri, 17 May 2013

=============
<!DOCTYPE HTML>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Test</title>
    <style type="text/css">
      td { width: 8em; }
      .yll { background:yellow; text-align:center; }
    </style>
  </head>
  <body>
    Table 1
    <table>
      <tr>
        <td>1a</td>
        <td class="yll">1b</td>
        <td>1c</td>
        <td class="yll">1d</td>
      </tr>
    </table>
    Table 2
    <table>
      <col><col class="yll"><col><col class="yll">
      <tr>
        <td>1a</td>
        <td>1b</td>
        <td>1c</td>
        <td>1d</td>
      </tr>
    </table>
  </body>
</html>
=============

In the code above there are 2 tables each with 4 columns. In the first
table the class .yll is applied directly to the 2nd and 4th cells. In
the second table I try to apply the class to the 2nd and 4th column
instead. Although, however, the respective cells turn yellow, their text
is not centered, Clearly the code has to be applied to the cells, not
the the columns.

I played with:
      col.yll td { background:yellow; text-align:center; }
but that of course doesn't work because the td is not inside the col.

What is the relation of the td to the col, and is there a way to change
the code in the header to make table 2 work?

Thanks,

emf

--
It ain't THAT, babe! - A radical reinterpretation
https://files.nyu.edu/emf202/public/bd/itaintmebabe.html

Replies