How to create a comparison table with CSS?

CSSWeb DevelopmentFront End Technology

To create a responsive table with CSS, the code is as follows −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
   table {
      border-collapse: collapse;
      border-spacing: 0;
      width: 100%;
      border: 1px solid #ddd;
   }
   th, td {
      text-align: center;
      padding: 16px;
      font-weight: bold;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      font-size: 18px;
   }
   th:first-child, td:first-child {
      text-align: left;
   }
   tr:nth-child(even) {
      background-color: #f2f2f2
   }
</style>
</head>
<body>
<h1 style="text-align: center;">Comparison Table Example</h1>
<table>
<tr>
<th style="width:50%">Features</th>
<th>Basic</th>
<th>Pro</th>
</tr>
<tr>
<td>Free</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>Customer Support</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Validity</td>
<td>1 Year</td>
<td>Lifetime</td>
</tr>
<tr>
<td>Warranty</td>
<td>No</td>
<td>5 Years</td>
</tr>
</table>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 07-May-2020 10:43:51
Advertisements