1D0-61B · Question #47
Which HTML element aligns content both horizontally and vertically to the center of the table cell by default?
The correct answer is C. <th>. <th> (table header) is the only table cell element that browsers render with both horizontal centering (text-align: center) and vertical centering (vertical-align: middle) applied by default, along with bold text. <td> is the most tempting distractor - it does vertically center…
Question
Which HTML element aligns content both horizontally and vertically to the center of the table cell by default?
Options
- A<tr>
- B<td>
- C<th>
- D<pre>
How the community answered
(37 responses)- A5% (2)
- B3% (1)
- C89% (33)
- D3% (1)
Explanation
<th> (table header) is the only table cell element that browsers render with both horizontal centering (text-align: center) and vertical centering (vertical-align: middle) applied by default, along with bold text. <td> is the most tempting distractor - it does vertically center content by default, but its horizontal alignment defaults to left, not center. <tr> defines a table row rather than a cell, so it holds no direct content and has no centering behavior. <pre> is entirely unrelated to tables - it preserves whitespace and uses a monospace font. Memory tip: Think "H for Header = Horizontally centered" - the <th> element is the headline of its column, so browsers emphasize it with bold + full centering by default, unlike the plain <td>.
Topics
Community Discussion
No community discussion yet for this question.