Tuesday, July 12, 2016

HTML- Styling tables with CSS

In this tutorial, we are going to learn about how to design tables in HTML with the help of CSS (Cascading Style Sheets). I took a look at wiki and made a decision to make a tutorial regarding video games. I have 5 games and their info and have designed it.

HTML code

<html>
<head>
<meta charset="utf-8"/>
<title> Styling Tables </title>
<link rel="stylesheet" href="styling tables.css">
</head>
<body>
<table border="1">
<caption> Best selling games according to Wiki</section>
<thead>
<tr>
<th> Rank </th>
<th> Title </th>
<th> Release year </th>
<th> Copies Sold </th>
</tr>
</thead>
<tbody>
<tr>
<td> 1 </td>
<td>Tetris</td>
<td>1984</td>
<td>143 million</td>
</tr>
<tr>
<td> 2 </td>
<td>Wii Sports</td>
<td>2006</td>
<td>81.99 million</td>saying th
</tr>
<tr>
<td> 3 </td>
<td>Minecraft</td>
<td>2009</td>
<td>49.5 million</td>
</tr>
<tr>
<td> 4 </td>
<td>Super Mario Brothers</td>
<td>1985</td>
<td>35.53 million</td>
</tr>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan=4> info from wikipedia </td>
</tr>
</tfoot>
</table>
</body>
</html>

CSS
table{
 border:1px solid black;
 border-collapse:collapse;
}

th,td{
 border:1px solid black;
 padding:5px;
}

tr:nth-child(2n) {
 background-color:#a0a0a0;
}

thead{
 background-color:#ccddee;
}

tfoot{
 background-color:#ddccee;
 text-align:center;
}

Output


No comments:

Post a Comment