Tables Questions with Answers

34 practice questions on Tables (HTML & CSS) with answers and step-by-step solutions. Try 10 samples below, then practise all 34 free in the AptiNest app.

Sample questions

Question 1Medium

How many kinds of cells are present in the table?

  1. 1
  2. 2
  3. 3
  4. 4

Answer: B. 2

Explanation

There are two types of cells are present in the table:-
1>header cell 2> data cell.

Step-by-step solution

  1. A table has header cells, made with th, and data cells, made with td.
  2. Standard HTML has no other kind of table cell.
  3. So there are 2 kinds of cells, and the correct answer 1 (2) is right.

Why the other options are wrong

  • A. 1 is wrong, because header cells and data cells are two kinds.
  • C. 3 kinds do not exist; the only two are header and data cells.
  • D. 4 kinds do not exist in standard HTML tables.

Tip: Th is for headings and td is for data. Those are the two cell types.

Question 2Medium

Which tag is used to align table caption to the top?

  1. < caption align="top">
  2. < caption="top">
  3. < caption place="top">
  4. None of these.

Answer: A. < caption align="top">

Explanation

The caption is located at the top of the table.
< caption align="top">Latest news</caption>

Step-by-step solution

  1. The caption tag gives the title of a table.
  2. The align attribute with the value top places the caption above the table.
  3. So the correct answer 0, caption with align='top', is right.

Why the other options are wrong

  • B. Caption is not an attribute name, so this is not valid.
  • C. Place is not a valid attribute; the correct attribute is align.
  • D. Option A is valid, so none of these is wrong.

Tip: Caption align can be top or bottom. Use align on caption, not a made-up attribute.

Question 3Medium

Which Specifies the number of columns to be spanned by this cell.

  1. Rowspan
  2. Colspan
  3. Tablespan
  4. None of these

Answer: B. Colspan

Explanation

colspan Specifies the number of columns to be spanned by this cell. The default value is "1".

Step-by-step solution

  1. Colspan is an attribute used in HTML tables.
  2. It defines how many columns a single cell should span across.
  3. The default value for colspan is 1 if not specified.
  4. This directly answers the question about spanning columns.
  5. Therefore, the correct answer is Colspan.

Why the other options are wrong

  • A. Rowspan spans rows down, not columns, so it answers a different question.
  • C. Tablespan is not a valid HTML attribute; the column-spanning one is colspan.
  • D. None of these is wrong, because Colspan is the correct attribute.

Tip: Remember: colspan merges cells across columns, rowspan merges them down rows.

Question 4Medium

Which tag is used to define table?

  1. <table>
  2. <tab>
  3. <t>
  4. None of these

Answer: A. <table>

Explanation

<table> tag is used to define table.

Step-by-step solution

  1. The HTML tag for a table is <table>.
  2. <tab> and <t> are not HTML tags.

Why the other options are wrong

  • B. <tab> is not an HTML tag.
  • C. <t> is not an HTML tag.
  • D. <table> is a valid tag, so 'None of these' is wrong.

Tip: The table tag is paired with a closing </table> tag.

Question 5Medium

How to set table width in percentage?

  1. < table width="50%">
  2. < width="50%">
  3. < table="50%">
  4. None of these.

Answer: A. < table width="50%">

Explanation

< table width="50%"> will set table width to 50% of its original width.

Step-by-step solution

  1. The width attribute goes on the table tag.
  2. A percentage width is relative to the space available.
  3. So the answer is table width 50%, option A.

Why the other options are wrong

  • B. No table tag is given, so the browser does not know which element to size.
  • C. Table is used as an attribute name here, and width is missing.
  • D. Option A is correct, so None of these is wrong.

Tip: Set width on the table tag, with a percent or pixel value.

Question 6Medium

How to show right and left outside borders?

  1. < table frame="hside">
  2. < table frame="above">
  3. < table frame="below">
  4. < table frame="vsides">

Answer: D. < table frame="vsides">

Explanation

The left and right outside borders are shown.

e.g.

< TABLE BORDER=8 FRAME=VSIDES RULES=NONE>

Step-by-step solution

  1. The frame attribute of a table controls which outside borders are drawn.
  2. Vsides draws the left and right outside borders.
  3. So frame='vsides' (option D) is the correct answer.

Why the other options are wrong

  • A. Hside is not a valid value; hsides draws only the top and bottom borders.
  • B. Above draws only the top border.
  • C. Below draws only the bottom border.

Tip: Frame values: void, above, below, hsides, vsides, lhs, rhs and box. vsides means the vertical sides.

Question 7Medium

Which table attribute defines the pixel space between cells?

  1. Cell padding
  2. Cell spacing
  3. Width
  4. Border

Answer: B. Cell spacing

Explanation

Cell spacing defines the pixel space between table cells.

Step-by-step solution

  1. Cell spacing sets the gap between table cells in pixels.
  2. It controls the empty space outside each cell but inside the table.
  3. This attribute directly defines the pixel space between cells.
  4. Other attributes like border or padding affect different parts of the cell.
  5. The correct answer is Cell spacing.

Why the other options are wrong

  • A. Cell padding sets the space inside each cell, between its border and content, not between cells.
  • C. Width sets the size of the table or column, not the gap between cells.
  • D. Border sets the outline of the table, not the space between cells.

Tip: Remember: Cell spacing controls the space between cells, not inside them.

Question 8Medium

How to show top and bottom outside borders?

  1. < table frame="box">
  2. < table frame="above">
  3. < table frame="below">
  4. < table frame="hsides">

Answer: D. < table frame="hsides">

Explanation

The top and bottom outside borders are shown.

e.g.

< TABLE BORDER=8 FRAME=HSIDES RULES=NONE>

Step-by-step solution

  1. The frame attribute on a table sets which outside borders show.
  2. The value hsides shows the top and bottom borders only.
  3. Box shows all four sides, above shows only the top, and below shows only the bottom.
  4. So the correct answer is option D, hsides.

Why the other options are wrong

  • A. Box shows all four outside borders, not only top and bottom.
  • B. Above shows only the top border.
  • C. Below shows only the bottom border.

Tip: Frame values: void none, above top, below bottom, hsides top and bottom, vsides left and right, box all four.

Question 9Medium

How to set frame only to the top of table?

  1. < table frame="box">
  2. < table frame="above">
  3. < table frame="below">
  4. < table frame="vsides">

Answer: B. < table frame="above">

Explanation

The option 'above' specifies that the frame should be applied only to the top of the table, which matches the requirement of the question.

Step-by-step solution

  1. Frame attribute sets borders around tables.
  2. The 'above' value adds a border only to the top.
  3. Other options add borders to different sides or all sides.
  4. So, < table frame="above"> is correct.

Why the other options are wrong

  • A. This adds a box border around all sides of the table.
  • C. This adds a border only to the bottom of the table.
  • D. This adds borders to left and right sides only.

Tip: Use frame="above" for top border only.

Question 10Medium

How to show right hand side border?

  1. < table frame="above">
  2. < table frame="below">
  3. < table frame="vsides">
  4. < table frame="rhs">

Answer: D. < table frame="rhs">

Explanation

The right outside border is shown.

< TABLE BORDER=8 FRAME=RHS RULES=NONE>

Step-by-step solution

  1. The frame attribute controls which outside borders a table shows.
  2. frame="rhs" shows only the right-hand side border.
  3. frame="above" shows only the top and frame="below" only the bottom border.
  4. So frame="rhs" is the correct answer.

Why the other options are wrong

  • A. Above draws only the top border.
  • B. Below draws only the bottom border.
  • C. Vsides draws both the left and right borders, not only the right one.

Tip: HTML table frame values: void, above, below, hsides, lhs, rhs, vsides, box, border.

Practise all 34 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all HTML & CSS topics · All topics