Is it possible to set cell padding and cell spacing in CSS?

If coding is more your thing then the Website Development & Scripting forums are for you. Share server-side scripting and database integration tips, tricks and problems here.
Post Reply
User avatar
radix24
Newbie
Posts: 5
Joined: Sun Sep 08, 2019 10:45 am

#1

Hello,

I know in an HTML table, the cell padding and cell spacing can set like this:

Code: Select all

<table cellspacing="1" cellpadding="1">
How can the same be accomplished using CSS?


User avatar
edwin
Junior Member
Posts: 31
Joined: Thu Sep 28, 2017 6:17 pm

#2

This works for all browsers.

Code: Select all

table {
    border-collapse: separate;
    border-spacing: 10px; /* cellspacing */
    *border-collapse: expression('separate', cellSpacing = '10px');
}

table td, table th {
    padding: 10px; /* cellpadding */
}
The * declaration is for Internet Explorer 6 and 7, and other browsers will properly ignore it.

Hope this help :)
User avatar
radix24
Newbie
Posts: 5
Joined: Sun Sep 08, 2019 10:45 am

#3

edwin wrote:
Mon Mar 30, 2020 9:40 pm
This works for all browsers.

Code: Select all

table {
    border-collapse: separate;
    border-spacing: 10px; /* cellspacing */
    *border-collapse: expression('separate', cellSpacing = '10px');
}

table td, table th {
    padding: 10px; /* cellpadding */
}
The * declaration is for Internet Explorer 6 and 7, and other browsers will properly ignore it.

Hope this help :)
Thank you, sir. it really helps me.
User avatar
edwin
Junior Member
Posts: 31
Joined: Thu Sep 28, 2017 6:17 pm

#4

you are most welcome :) Stay Safe, Stay Home
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests