Table header with border : th border « Tags « HTML / CSS






Table header with border

     

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title> HTML tables </title>
        <style type='text/css'>
            table {
                width: 300px;
                caption-side: bottom;
                border: thin solid black;
                table-layout: fixed;
                border-spacing: 0;
                margin: 5px;
            }
            th, td {
                border: thin solid black;
                text-align: center;
                font-weight: bold;
                overflow: hidden;
            }
            th {
                background: lightgrey;
            }
            td {
                vertical-align: top;
            }
            caption {
                font-size: 90%;
                text-align: right;
            }
            td, th, caption {
                padding: 5px;
            }
        </style>        
    </head>
    <body>
        <table>
            <caption>
                My favorite movies.
            </caption>
            <colgroup>
                <col id='movie' />
                <col id='cast' />
                <col id='genre' />
                <col id='year' />
            </colgroup>
            <thead>
                <tr>
                    <th> movie            </th>
                    <th> stars            </th>
                    <th> genre            </th>
                    <th> year             </th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td> B</td>
                    <td> J</td>
                    <td> C</td>
                    <td> 2</td>
                </tr>
                <tr>
                    <td> T</td>
                    <td> E</td>
                    <td> A</td>
                    <td> 2</td>
                </tr>
                <tr>
                    <td> T</td>
                    <td> K</td>
                    <td> A</td>
                    <td> 2</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

   
    
    
    
  








Related examples in the same category

1.Set table header border to be 1px solid black, its width to 6em
2.Set table border for table header
3.th border-left: 1px solid #f4f4f4;
4.th border-bottom: solid 2px #fff;
5.th border-left: 1px solid #EDC9C9;
6.th border-bottom: 1px solid #FFF;
7.th border-left: 1px solid #fff;
8.th border: 1px solid black;
9.th border-bottom-width: 1px;
10.th border-bottom-style: solid;
11.th border-bottom-color: #CDC1A7;
12.th, tfoot td border: thin solid black;text-align: center;font-weight: bold;
13.thead th {border-bottom: 1px solid #333; text-align: center; font-weight: bold;}
14.th[scope="col"] {border-bottom: 1px solid gray;}