In HTML table design, which attribute specifies, in pixels, the distance between the borders of two adjacent table cells?

Difficulty: Easy

Correct Answer: cellspacing

Explanation:


Introduction / Context:
When designing web pages with HTML tables, it is often necessary to control the spacing and layout of cells for clarity and readability. Two important attributes traditionally used in table markup are cellpadding and cellspacing. Although modern web design typically uses Cascading Style Sheets, understanding these classic attributes remains valuable for computer awareness exams and for interpreting legacy code. This question asks you to identify which attribute controls the distance between the borders of adjacent table cells, measured in pixels.


Given Data / Assumptions:

  • We are dealing with HTML table design.
  • The spacing is measured in pixels.
  • The spacing described is between two adjacent table cells, not inside the cell.
  • The options include width, height, cellpadding, cellspacing and border.
  • Only one attribute correctly matches the described behaviour.


Concept / Approach:
In older HTML table attributes, cellpadding specifies the space between the cell content and the cell border, essentially the internal padding. Cellspacing specifies the space between the borders of neighbouring table cells, which creates visible gaps between them. The width and height attributes control dimensions of elements rather than spacing between cells, and border controls the thickness of the table border line. Therefore, when the question refers to the distance between two adjacent cells, the correct attribute is cellspacing.


Step-by-Step Solution:
Step 1: Identify that the question is about spacing between cells, not inside a single cell.Step 2: Recall the difference between cellpadding and cellspacing in HTML table markup.Step 3: Recognise that cellpadding affects the inner space between content and border, whereas cellspacing affects the outer space between cells.Step 4: Eliminate width and height because they refer to size, not separation between cells.Step 5: Eliminate border because it refers to border thickness, not gap distance.Step 6: Select cellspacing as the attribute that matches the definition given.


Verification / Alternative check:
If you imagine a simple HTML table and set cellpadding to 10 and cellspacing to 0, you will see that each cell has extra space inside, but there is no gap between cell borders. If you instead set cellpadding to 0 and cellspacing to 10, the cell content touches the border, but there is a clear gap between the borders of adjacent cells, making them appear separated. This visual behaviour is consistently described in HTML tutorials and confirms that cellspacing controls the distance between table cells. This observation verifies that the answer must be cellspacing, not any of the other attributes.


Why Other Options Are Wrong:

  • Width sets the width of the table or column, not the gap between cells.
  • Height sets the vertical size of an element, not spacing between neighbouring table cells.
  • Cellpadding sets the space inside the cell between the content and the cell border, not between two different cells.
  • Border sets the thickness of the border line around the table and cells rather than the distance between their borders.


Common Pitfalls:
A common confusion is between cellpadding and cellspacing, because both terms refer to spacing. Many learners remember that one is inside and one is outside but cannot recall which is which. To avoid this, connect the word cell with the inside and think of padding as internal, whereas spacing suggests a gap between objects. Also, be careful not to assume modern CSS properties when a question clearly refers to classic HTML attributes. Recognising that cellspacing is about the space between cells will help you answer similar questions correctly.


Final Answer:
The correct answer is cellspacing, which specifies in pixels the distance between the borders of two adjacent HTML table cells.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion