
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create a Comparison Table with CSS
To create a responsive table with CSS, the code is as follows −
Example
<!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 −
Advertisements