Which attribute of table sets the width, in pixel, between the edge of cell…

2024

Which attribute of table sets the width, in pixel, between the edge of cell and its contents?

Answer: A. CellpaddingConceptIn classic HTML table markup, white space around cell content is governed by two attributes written on the <table> element, and they are told apart by…

  1. A.

    Cellpadding

  2. B.

    Cellspacing

  3. C.

    Cols

  4. D.

    Rows

Attempted by 307 students.

Show answer & explanation

Correct answer: A

Concept

In classic HTML table markup, white space around cell content is governed by two attributes written on the <table> element, and they are told apart by which side of the cell border the space falls on. Space enclosed within a cell's own border is the cell's internal padding; space lying outside the border is what separates one cell from the next. Both attributes take their value as a number of pixels.

Applying it to this question

The stem asks for the width, in pixels, between the edge (border) of a cell and its contents — that is space lying inside the border, so it is the cell's internal padding. Classic table markup exposes internal padding as the cellpadding attribute. Writing <table cellpadding="10"> makes every cell hold its content 10 pixels away from its own border on all four sides.

The four attributes side by side

Attribute

Written on

What its value means

cellpadding

<table>

pixels between a cell's border and its content (inside the border)

cellspacing

<table>

pixels between the borders of neighbouring cells (outside the border)

cols

<textarea>

how many character columns wide the text box is (a count, not pixels)

rows

<textarea>

how many rows of text tall the text box is (a count, not pixels)

Cross-check

Modern CSS replaces both table attributes, and the replacement confirms the split: internal space becomes the padding property on td and th, while the gap between cells becomes border-spacing on the table. Since padding is what moves a cell's text away from its own border, the attribute the stem describes is cellpadding. Note that the names cols and rows also appear on the obsolete <frameset> element, where each takes a comma-separated list of frame sizes such as "20%,80%" rather than a single count; either way they size a whole element and never the space inside a table cell.

Explore the full course: Rssb Basic Computer Instructor

Loading lesson…