How can I add borders to my table?

Table Borders



 Certainly! To add borders to an HTML table, you can use CSS. Let’s break it down:

  1. Basic Border:

    • Apply the CSS border property to the <table>, <th>, and <td> elements.
    • Example:
      <style>
        table, th, td {
          border: 1px solid black;
        }
      </style>
      
    • This creates a 1px solid black border around the entire table, headers, and cells.
  2. Collapsed Borders:

    • To avoid double borders between adjacent cells, set border-collapse: collapse;.
    • Example:
      <style>
        table, th, td {
          border: 1px solid black;
          border-collapse: collapse;
        }
      </style>
      
  3. Invisible Border (Styling Trick):

    • Set the border color to match the background color (e.g., white).
    • Example:
      <style>
        table, th, td {
          border: 1px solid white;
          border-collapse: collapse;
        }
        th, td {
          background-color: #96D4D4;
        }
      </style>
      
  4. Rounded Corners:

    • Use border-radius to create rounded corners for the table.
    • Example:
      <style>
        table, th, td {
          border: 1px solid black;
          border-radius: 10px;
        }
      </style>
      

Remember, CSS styling is essential for effective table presentation. Feel free to experiment with these examples! 🌐🎨 123

Check this also-How do I create a clickable image link in HTML?

 

💡 Enjoying the content?

Subscribe to our BLOG

Post a Comment

0 Comments