ProfK
ProfK

Reputation: 51064

Why doesn't my first HTML table column have bold text?

My understanding of the col tag tells me that the following should style text in my first table column as bold, but this is not happening. What am I doing wrong?

<table class="span-12">
    <col style="font-weight: bold;" />
    <col />
    <tr>
        <td>
            Client
        </td>
        <td>
            Apartment Applied Visual Arts
        </td>
    </tr>
</table>

Upvotes: 5

Views: 8254

Answers (3)

JacquesB
JacquesB

Reputation: 42669

col (and colgroup) elements are somewhat special wrt. CSS. Since table rows and cells are not descendants of cols, CSS formatting does not inherit from from col to cells.

There is however four CSS properties which can be applied to col and colgroup and which will affect the cells. These are border, background, width and visibility. Each have specific algorithms for how the properties are resolved on the cells.

But since font-weight is not one of these four properties, it does not have any effect in your example.

Upvotes: 1

Kalle H. V&#228;ravas
Kalle H. V&#228;ravas

Reputation: 3615

This is not the correct way of using , but you can try this:

<table class="span-12">
    <tr>
        <th>
            Client
        </th>
        <td>
            Apartment Applied Visual Arts
        </td>
    </tr>
</table>

However, you must add some css to it table.span-12 th {text-align: left;}

OR

<style>
table.span-12 .fat {font-weight: bold;}
</style>

<table class="span-12">
    <tr>
        <th class="fat">
            Client
        </th>
        <td>
            Apartment Applied Visual Arts
        </td>
    </tr>
</table>

Upvotes: 4

Quentin
Quentin

Reputation: 943605

The table data cells are not descendants of the col element, so they do not inherit any properties from it. See the columns section of the CSS specification.

Upvotes: 6

Related Questions