• Home
  • Html
  • CSS
  • Angular
  • Aws Cloud
  • Java
  • JavaScript
  • PHP
  • React
  • SQL
  • WordPress
  • Source Code
  • Bulk Qr Code Generator
  • Home
  • Html
  • CSS
  • Angular
  • Aws Cloud
  • Java
  • JavaScript
  • PHP
  • React
  • SQL
  • WordPress
  • Source Code
  • Bulk Qr Code Generator
  • Html
    • HTML Elements
    • HTML - History
    • HTML Editors
    • HTML tags
    • HTML Paragraphs
    • HTML comments
    • HTML - Phrase Tags
    • HTML Image
    • HTML Style
    • HTML Quotation
    • HTML Responsive
    • Class HTML
  • HTML Tables
    • HTML Tables
    • HTML Header
    • HTML - Table Styling

HTML - Table Styling

13 views 0

HTML – Table Styling

You have the flexibility to manage the space between table borders by manipulating the ‘border-collapse’ property. This property determines how adjacent table cell borders interact, and adjusting it allows you to control the spacing or gap between the borders within your table.

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}

tr:nth-child(even) {
  background-color: rgba(150, 212, 212, 0.4);
}

th:nth-child(even),td:nth-child(even) {
  background-color: rgba(150, 212, 212, 0.4);
}
</style>
</head>
<body>

<h2>Striped Table</h2>
<p>For zebra-striped tables, use the nth-child() selector and add a background-color to all even (or odd) table rows:</p>

<table style="width:100%">
  <tr>
    <th>MON</th>
    <th>TUE</th>
    <th>WED</th>
    <th>THU</th>
    <th>FRI</th>
    <th>SAT</th>
    <th>SUN</th>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
</table>

</body>
</html>



How to adjust table layout in HTML?

Inline styles also let you control your table’s layout, including its width, spacing, and padding. The border-collapse property is especially useful for deciding if table borders are separated or merged into a single border.

<table style="border-collapse: collapse; width: 100%;">
  <tr>
    <td style="border: 1px solid black; padding: 20px;">Cell 1</td>
    <td style="border: 1px solid black; padding: 20px;">Cell 2</td>
  </tr>
</table>

 

Tags:html tutorialHTML - Table Stylinghtml

Didn't find your answer? Contact Us

Previously
HTML Header

Didn't Find an Answer?

Get in touch with us for details on setup and additional custom services pricing

Contact Us

    Copyright 2025 interntpoint. All Rights Reserved
    Popular Search:Getting Started