proper CSS style for HTML table

When using table in HTML, you should use CSS style. Indeed, the old way that consists of setting attributes within the table (and td/tr/th) tag is deprecated.

Therefore this old code

<table width="400" border="3" cellpadding="5" cellspacing="2">
    <tr bgcolor="#DDDDDD">
        <td width="100" align="left"><b>Some text</b></td>
        <td align="right">some data</td>
    </tr>
 </table>

should be replaced by

<table id="download">
<tr>
  <td class="leftcol">Some text  </td>
  <td >Some data  </td>
</tr>
</table>

Where a CSS file would contain the information related to the id download and the class leftcol:

table#download {
    background-color:#FFFFFF;
    border: solid #000 3px;
 }
 table#download td {
    padding: 5px;
    border: solid #000 1px;
 }
 
.leftcol {
    font-weight: bold;
    text-align: left;
    background-color: #bfbfbf;
 }
Please follow and like us:
This entry was posted in Computer Science and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *