Add column headings to a table


We're going to use the table heading tag (<th>) to add a column headings to a table like this:

Ship Speed
Dragon Ship fast
Ferry slow
  1. write a table in the code
    <table border="1">
    	<tr>
    		<td>Ship</td>
    		<td>Speed</td>
    	</tr>
    	<tr>
    		<td>Dragon Ship</td>
    		<td>fast</td>
    	</tr>
    	<tr>
    		<td>Ferry</td>
    		<td>slow</td>
    	</tr>
    </table>
    		
  2. save the code and open the page in a browser
    you'll see this:
    Ship Speed
    Dragon Ship fast
    Ferry slow
  3. Now, let's make "Ship" and "Speed" the headings of their columns by changing <td> to <th> in the code:
    <table border="1">
    	<tr>
    		<th>Ship</th>
    		<th>Speed</th>
    	</tr>
    	<tr>
    		<td>Dragon Ship</td>
    		<td>fast</td>
    	</tr>
    	<tr>
    		<td>Ferry</td>
    		<td>slow</td>
    	</tr>
    </table>
    		
  4. save the code and open the page in a browser
    you'll see this:
    Ship Speed
    Dragon Ship fast
    Ferry slow

    "Ships" and "Speed" have been made bold and centred by the <th> tag!

more tutorials to try


you might like to try these tutorials too:

Go Berserk Book

Buy Now to buy for
£11.99 US$17.99 €13.99 (not incl. P&P)
for 1 or 2 books
Buy more and save!
Email sales@go-berserk.com
for 3 books or more.



Go Berserk CSS Book

Buy Now to buy for a special price of
£8.99 US$13.99 €11.99 (not incl. P&P)
for 1 or 2 books
Buy more and save!
Email sales@go-berserk.com
for 3 books or more.