Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

<!

DOCTYPE html>

<html>

<head>

<style>

table, th, td {

border: 1px solid black;

border-collapse: collapse;

</style>

</head>

<body>

<h2>Table With Border</h2>

<p>Use the CSS border property to add a border to the table.</p>

<table style="width:100%">

<tr>

<th>Firstname</th>

<th>Lastname</th>

<th>Age</th>

</tr>

<tr>

<td>Rahul</td>

<td>Kumar</td>

<td>50</td>

</tr>

<tr>

<td>Riya</td>

<td>Pandey</td>

<td>24</td>
</tr>

<tr>

<td>Anurag</td>

<td>Rao</td>

<td>30</td>

</tr>

</table>

</body>

</html>

<!DOCTYPE html>

<html>

<head>

<style>

table, th, td {

border: 1px solid black;

border-collapse: collapse;

th, td {

padding: 15px;

</style>

</head>

<body>

<h2>Cellpadding</h2>

<p>Cell padding specifies the space between the cell content and its borders.</p>

<table style="width:100%">

<tr>
<th>Firstname</th>

<th>Lastname</th>

<th>Age</th>

</tr>

<tr>

<td>Rahul</td>

<td>Kumar</td>

<td>50</td>

</tr>

<tr>

<td>Riya</td>

<td>Pandey</td>

<td>24</td>

</tr>

<tr>

<td>Anurag</td>

<td>Rao</td>

<td>30</td>

</tr>

</table>

<p><strong>Tip:</strong> Try to change the padding to 5px.</p>

</body>

</html>

You might also like