Skip to content

Buzzingz

Unleashing the Power of Code

  • HTML
  • CSS
  • JavaScript
  • Toggle search form

Table Borders

Posted on March 4, 2023April 1, 2023 By shani No Comments on Table Borders

Table borders can be added to HTML tables using CSS. You can add borders to the table itself, as well as the table cells.

To add a border to the table, you can use the border property in CSS. Here’s an example:

<style>
table {
  border: 1px solid black;
}
</style>

<table>
  <tr>
    <th>Header 1</th>
    <th>Header 2</th>
  </tr>
  <tr>
    <td>Cell 1</td>
    <td>Cell 2</td>
  </tr>
  <tr>
    <td>Cell 3</td>
    <td>Cell 4</td>
  </tr>
</table>

In this example, the border property is used to add a 1-pixel solid black border to the entire table.

To add borders to the table cells, you can use the border property on the td and th elements. Here’s an example:

<style>
table {
  border-collapse: collapse;
}
td, th {
  border: 1px solid black;
  padding: 8px;
}
</style>

<table>
  <tr>
    <th>Header 1</th>
    <th>Header 2</th>
  </tr>
  <tr>
    <td>Cell 1</td>
    <td>Cell 2</td>
  </tr>
  <tr>
    <td>Cell 3</td>
    <td>Cell 4</td>
  </tr>
</table>

In this example, the border-collapse property is used to collapse the borders of adjacent cells, creating a more seamless appearance. The td and th elements are styled with a 1-pixel solid black border and 8 pixels of padding.

You can also add different border styles, colors, and widths to the table and cells using CSS. With a little bit of experimentation, you can create tables that are visually appealing and easy to read.

HTML

Post navigation

Previous Post: HTML Tables
Next Post: HTML Table Sizes

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

HTML Tutorial

  • HTML History
  • HTML Editors
  • What is an HTML Element?
  • HTML Attributes
  • HTML Headings
  • HTML Paragraphs
  • HTML Styles
  • HTML Text Formatting
  • HTML Quotation and Citation Elements
  • HTML Comments
  • HTML Colors
  • HTML Styles – CSS
  • HTML Links
  • HTML images
  • HTML Favicon
  • HTML Tables
    • HTML Table Colgroup
    • HTML Table Colspan and Rowspan
    • HTML Table Headers
    • HTML Table Padding and Spacing
    • HTML Table Sizes
    • HTML Table Styling
  • HTML List
  • HTML Ordered Lists
  • HTML Unordered List
  • HTML other lists
  • HTML Block and Inline Elements
  • HTML class Attribute
  • HTML id Attribute
  • HTML Iframes
  • HTML JavaScript
  • HTML File Paths
  • HTML – The Head Element
  • HTML Layout Elements and Techniques
  • HTML Responsive Web Design
  • HTML Computer Code Elements
  • HTML Semantic Elements
  • HTML Style Guide
  • HTML Entities
  • HTML Symbols
  • HTML Emojis
  • HTML Encoding (Character Sets)
  • HTML Uniform Resource Locators(URL)
  • HTML Versus XHTML
  • HTML Forms
  • HTML Form Attributes
  • HTML Form Elements
  • HTML Form Target Attribute
  • HTML Input Attributes
  • HTML Input form Attributes
  • HTML Input Types
  • HTML Canvas Graphics
  • HTML SVG Graphics
  • HTML Multimedia
  • HTML Video
  • HTML Audio
  • HTML Plug-ins
  • HTML YouTube Videos
  • HTML Geolocation API
  • HTML Drag and Drop API
  • HTML Web Storage API
  • HTML Web Workers API
  • HTML SSE API
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions

Copyright © 2023 Buzzingz.

Powered by PressBook WordPress theme