Which of the following property of a table element specifies the width that should appear between table cells?

border-collapse
border-spacing
caption-side
empty-cells

The correct answer is: B. border-spacing

The border-spacing property specifies the width of the space between the borders of adjacent cells in a table. It can be set to a length value, such as 1px or 2em, or to a percentage value, such as 5%.

The border-collapse property specifies how the borders of adjacent cells are collapsed. It can be set to the values collapse, separate, or inherit.

The caption-side property specifies the position of the table caption. It can be set to the values top, bottom, or left.

The empty-cells property specifies how empty cells are rendered in a table. It can be set to the values show, hide, or inherit.

Here is an example of how the border-spacing property can be used:

“`html

Cell 1 Cell 2
Cell 3 Cell 4

“`

Without any CSS, the table would look like this:

┌─────┬─────┐
| Cell 1 | Cell 2 |
└─────┴─────┘
| Cell 3 | Cell 4 |
└─────┴─────┘

If we add the following CSS:

css
table {
border-spacing: 10px;
}

The table would look like this:

┌───────┬───────┐
| Cell 1 | Cell 2 |
└───────┴───────┘
| Cell 3 | Cell 4 |
└───────┴───────┘

As you can see, the border-spacing property has added a 10px space between the borders of adjacent cells.

Exit mobile version