Q:
Adding cellpadding,cellspacing,margin
I need to add cellpadding, cellspacing and margin to a table.
.wrapper {
border-collapse: collapse;
margin-bottom: 15px;
}
.wrapper th,.wrapper td {
text-align: center;
vertical-align: middle;
.wrapper th {
padding: 5px;
.wrapper td {
.wrapper tr {
background-color: #fff;
Subject Name
Number of Words
Number of Pages
Word Count
I tried to change it to
border-collapse: collapse;
margin-bottom: 15px;
padding-left: 30px;
text-align: center;
vertical-align: middle;
padding-right: 30px;
padding: 5px;
background-color: #fff;
It still doesn't show padding (or margin) but it does add cellpadding.
A:
This is actually because margin and padding are applied to s and s separately and when the table is set to a specific width, all content will be shifted to the right (or left) as they don't expand in size with the available space and due to the horizontal spacing you have in your first attempt.
When you use:
padding-left: 30px;
You are setting the margin and padding to 30px (or rather the first box inside.wrapper).
So
Related links:
Comentarios