In HTML, `cellpadding` and `cellspacing` are attributes that are used to control the spacing between table cells. However, they are not CSS properties and cannot be set using CSS.
Instead, you can use CSS to control the spacing between table cells by setting the `border-spacing` or `border-collapse` properties on the table element. Here's an example:
table {
border-spacing: 10px; /* Set the spacing between cells */
border-collapse: separate; /* Make sure the borders between cells are visible */
}
In this example, we're setting the `border-spacing` property to `10px`, which will create a 10-pixel gap between adjacent cells in the table. We're also setting the `border-collapse` property to `separate`, which ensures that the borders between cells are visible.
Note that `border-spacing` is a shorthand property for setting both the horizontal and vertical spacing between cells. If you need to set different horizontal and vertical spacing, you can use the `border-spacing` property with two values, like this:
table {
border-spacing: 10px 5px; /* Set 10 pixels horizontal spacing and 5 pixels vertical spacing */
border-collapse: separate;
}
Again, note that `cellpadding` and `cellspacing` are not CSS properties and cannot be set directly with CSS.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
In HTML, `cellpadding` and `cellspacing` are attributes that are used to control the spacing between table cells. However, they are not CSS properties and cannot be set using CSS.
Instead, you can use CSS to control the spacing between table cells by setting the `border-spacing` or `border-collapse` properties on the table element. Here's an example:
In this example, we're setting the `border-spacing` property to `10px`, which will create a 10-pixel gap between adjacent cells in the table. We're also setting the `border-collapse` property to `separate`, which ensures that the borders between cells are visible.
Note that `border-spacing` is a shorthand property for setting both the horizontal and vertical spacing between cells. If you need to set different horizontal and vertical spacing, you can use the `border-spacing` property with two values, like this:
Again, note that `cellpadding` and `cellspacing` are not CSS properties and cannot be set directly with CSS.