Which of the following HTML5 codes will affect the horizontal as well as…
2018
Which of the following HTML5 codes will affect the horizontal as well as vertical alignment of the table content ?
- A.
<td align=”middle” valign = center; vertical-align: middle;”>BASH</td>
- B.
<td style=”horizontal-align: center; vertical-align: middle;”>BASH</td>
- C.
<td style= “text-align: center; vertical-align: middle;”>BASH</td>
- D.
<td halign=”middle” valign = “center”>BASH</td>
Attempted by 304 students.
Show answer & explanation
Correct answer: C
Solution:
The correct answer is Option C:
✔️ <td style="text-align: center; vertical-align: middle;">BASH</td>
Explanation:
In HTML5, presentation-related attributes like align and valign are deprecated. Instead, CSS is used to control the layout and alignment of content.
text-align: center;is a valid CSS property that controls the horizontal alignment of text or inline content inside the<td>element.vertical-align: middle;is used to align the content vertically at the center within the table cell.
Together, these two properties ensure that the content (“BASH”) is centered both horizontally and vertically.
Why other options are incorrect:
Use of
align,valign, orhalign→ deprecated or invalid in HTML5Incorrect values like
"middle"foralign→ invalidInvalid CSS property like
horizontal-align→ does not existMixing HTML attributes with CSS improperly → incorrect syntax
Conclusion:
Option C is correct because it follows modern HTML5 standards by using CSS within HTML to achieve both horizontal and vertical alignment in a standards-compliant way.
A video solution is available for this question — log in and enroll to watch it.