Categories
CSS

How to set cellpadding and cellspacing in CSS?

Spread the love

Sometimes, we want to set cellpadding and cellspacing in CSS.

In this article, we’ll look at how to set cellpadding and cellspacing in CSS.

How to set cellpadding and cellspacing in CSS?

To set cellpadding and cellspacing in CSS, we set the padding and border properties.

For instance, we write

td {
  padding: 10px;
}

table {
  border-spacing: 10px;
  border-collapse: separate;
}

to add cell spacing with the border-spacing property.

border-collapse: separate; is required to apply border-spacing

And we add cell padding with the padding property for td’s.

Conclusion

To set cellpadding and cellspacing in CSS, we set the padding and border properties.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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