Reputation: 1541
I'm trying to format a table in HTML, but I can't seem to get it to work. I want everything to be left aligned and font-size 125%. The header should be blue, while everything else should be black.
As of now, the table will have all black text, but properly sized. The header isn't left aligned, but instead has seemingly random tabbing in between. I had made some changes to th that would for some reason affect the entire table. I can't seem to replicate that, though (forgot how I did it).
Here's my code:
<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
<head>
<style type='text/css'>
p {margin: 0em 0 0em 0;}
th {color: blue; text-align: left;}
tr {color: black;text-align: left;}
table {font-size:125%;}
</style>
<meta content='text/html; charset=ISO-8859-1'http-equiv='content-type'>
<title>Test Results</title>
</head>
<body>
<table>
<th>
<td>Test</td>
<td>Status</td>
<td>DateTime</td>
<td>Blank Lines</td>
</th>
<tr>
<td>TestNameHere</td>
<td>PASSEd</td>
<td>20140730 15:13:13</td>
<td>1,3,5,2,7,9</td>
</tr>
</table>
</body>
</html>
I'm still pretty new to this, but the formatting seems to match everything I've seen online. I tried putting the colors in hex, but it didn't change anything.
Upvotes: 0
Views: 579
Reputation: 4364
This works fiddle
HTML
<table>
<tr>
<th>Test</th>
<th>Status</th>
<th>DateTime</th>
<th>Blank Lines</th>
</tr>
<tr>
<td>TestNameHere</td>
<td>PASSEd</td>
<td>20140730 15:13:13</td>
<td>1,3,5,2,7,9</td>
</tr>
</table>
CSS
p {margin: 0em 0 0em 0;}
th {color: blue; text-align: left;}
tr {color: black;text-align: left;}
table {font-size:125%;}
your problem was you used <th>
instead of <tr>
and where you should give <th>
for heading, you gave <td>
Upvotes: 1