Set cellpadding and cellspacing in CSS

0 votes
In an HTML table, the cellpadding and cellspacing can be set like this:

<table cellspacing="1" cellpadding="1">
How can the same be accomplished using CSS?
May 31, 2022 in CSS by Edureka
• 13,620 points
590 views

1 answer to this question.

0 votes

For controlling "cellpadding" in CSS, you can simply use padding on table cells. E.g. for 10px of "cellpadding":

td { 
    padding: 10px;
}

For "cellspacing", you can apply the border-spacing CSS property to your table. E.g. for 10px of "cellspacing":

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

This property will even allow separate horizontal and vertical spacing, something you couldn't do with old-school "cellspacing".

answered Jun 10, 2022 by Edureka
• 12,690 points

Related Questions In CSS

0 votes
1 answer

when declaring css styles, what is the meaning of .classA.classB (two class names with a dot in the middle and no space)

The first example (space-separated classes) is a ...READ MORE

answered Jun 28, 2022 in CSS by Edureka
• 12,690 points
773 views
0 votes
1 answer

How to include bootstrap css and js in reactjs app?

To begin, we will use npm to ...READ MORE

answered Jul 4, 2022 in CSS by Edureka
• 320 points
746 views
0 votes
0 answers

How do negative margins in CSS work and why is (margin-top:-5 != margin-bottom:5)?

A common trick for vertical positioning elements ...READ MORE

Jul 18, 2022 in CSS by Edureka
• 13,620 points
971 views
0 votes
0 answers

horizontal line and right way to code it in html, css

I need to draw a horizontal line ...READ MORE

Jul 22, 2022 in CSS by Edureka
• 13,620 points
352 views
0 votes
0 answers

Set cellpadding and cellspacing in CSS?

In an HTML table, the cellpadding and ...READ MORE

Jun 8, 2022 in HTML by Ashwini
• 5,430 points
440 views
0 votes
0 answers

How can I vertically center a div element for all browsers using CSS?

I want to center a div vertically with CSS. ...READ MORE

Jun 22, 2022 in CSS by Edureka
• 13,620 points
476 views
0 votes
1 answer

Best way to center a <div> on a page vertically and horizontally?

The legitimate way to do that irrespective ...READ MORE

answered Jun 28, 2022 in CSS by Edureka
• 12,690 points
583 views
0 votes
0 answers

Table scroll with HTML and CSS

I have a table like that which ...READ MORE

Jul 8, 2022 in CSS by Edureka
• 13,620 points
1,821 views
0 votes
1 answer

How to set Bullet colors in UL/LI html lists via CSS without using any images or span tags

I use jQuery for this: jQuery('li').wrapInner('<span class="li_content" />'); & ...READ MORE

answered May 27, 2022 in CSS by Edureka
• 12,690 points
1,061 views
0 votes
1 answer

I want to create a small square colour filled box in HTML & CSS. And most important - I want to write one line after the box

Try using the square html entity: <div style="color:blue">&a ...READ MORE

answered Jun 28, 2022 in CSS by Edureka
• 12,690 points
5,781 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP