Useful table styles
border-collapse: collapse;— merges double borders into onepaddingonthandtd— space inside cellstext-align— align cell contenttr:nth-child(even)— striped rowstr:hover— highlight the row under the mouse
Responsive tables
Wrap the table in a div with overflow-x: auto; so it scrolls sideways on small screens.
Example
Example — Striped table with hover
HTML
<style>
.wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; }
th, td { border: 1px solid #ddd; padding: 10px; text-align: left; }
th { background: #1f386b; color: white; }
tr:nth-child(even) { background: #f4f7fc; }
tr:hover { background: #fff3cd; }
</style>
<div class="wrap">
<table>
<tr><th>Course</th><th>Topics</th><th>Level</th></tr>
<tr><td>HTML</td><td>33</td><td>Beginner</td></tr>
<tr><td>CSS</td><td>38</td><td>Beginner</td></tr>
<tr><td>JavaScript</td><td>40</td><td>Intermediate</td></tr>
</table>
</div>