Skip to content

Buzzingz

Unleashing the Power of Code

  • HTML
  • CSS
  • JavaScript
  • Toggle search form

HTML Table Padding and Spacing

Posted on March 4, 2023April 1, 2023 By shani No Comments on HTML Table Padding and Spacing

HTML provides two attributes to control the space between table cells and the space between the table border and its contents. These attributes are:

  1. cellpadding: This attribute specifies the amount of space between the content of a table cell and its border. It takes a pixel or percentage value. Here’s an example:
<table cellpadding="10">
  <tr>
    <td>Cell 1</td>
    <td>Cell 2</td>
  </tr>
</table>

In this example, the cellpadding attribute is set to 10 pixels, which adds 10 pixels of space between the content of each cell and its border.

  1. cellspacing: This attribute specifies the amount of space between the cells of a table. It takes a pixel or percentage value. Here’s an example:
<table cellspacing="10">
  <tr>
    <td>Cell 1</td>
    <td>Cell 2</td>
  </tr>
</table>

In this example, the cellspacing attribute is set to 10 pixels, which adds 10 pixels of space between each cell in the table.

It’s worth noting that these attributes are considered outdated and have been replaced by CSS. You can achieve the same effect using CSS properties like padding and border-spacing. Here’s an example:

<style>
  table {
    border-spacing: 10px;
  }
  td {
    padding: 10px;
  }
</style>
<table>
  <tr>
    <td>Cell 1</td>
    <td>Cell 2</td>
  </tr>
</table>

In this example, the border-spacing property is used to add space between the cells, and the padding property is used to add space between the cell content and its border. This approach separates the presentation of the table from its content and is considered a best practice.

HTML

Post navigation

Previous Post: HTML Table Headers
Next Post: HTML Table Colspan and Rowspan

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