HTML Questions & Answers – Working with Tables

This set of HTML Multiple Choice Questions & Answers (MCQs) focuses on “Working with Tables”.

1. Each cell of the table can be represented by using __________
a) <tr>
b) <td>
c) <th>
d) <thead>
View Answer

Answer: b
Explanation: td stands for table data, we can represent each cell of the table by using <td>, at the end we used </td> tag. But some browsers by default draw the lines around table. <tr> is used to indicate start of every row i.e. it stands for table row. The header information is present in <th> tag. <thead> tag contains the group of header.

2. For heading we can use ____________
a) <td>
b) <tr>
c) <thead>
d) <th>
View Answer

Answer: d
Explanation: <th> element is used for representing heading of column or a row. It works same as <td> element. If shell has no content we can use <th> element also there. We can use scope attribute for specifying the heading is for row or column. Usually content of <th> is represented in bold. <thead> tag contains the group of header. <tr> is used to indicate start of every row i.e. it stands for table row.

3. Headings of table lies inside ___________
a) <thead>
b) <tfoot>
c) <th>
d) <tbody>
View Answer

Answer: a
Explanation: Headings of the table lies inside <thead> element. Footer lies inside the <tfoot> element. The body of the table lies inside <tbody> element. <th> is used for giving heading to a row or a column. Every element must have closing tag also i.e. </thead>, </tfoot>, </tbody>
advertisement
advertisement

4. Which of the following is not the element associated with HTML table layout?
a) size
b) spanning
c) alignment
d) color
View Answer

Answer: d
Explanation: There are three elements in HTML table layout i.e. size, spanning and alignment. Layout type can be achieved by setting Rows elements layout attribute to Fixed or Auto. Auto attribute relies on browser compatibility whereas fixed layout relies on developer specification.

5. Which of the following element is not associated with a class attribute?
a) Row
b) <thead>
c) Column cell
d) Rows
View Answer

Answer: b
Explanation: Column cell, Row, and Rows are the container elements. They have a class attribute with the help of this we can apply special styling. Table alignment is also controlled style sheet classes. Text-align and vertical-align are the style attributes that align the content of the table.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. For adding caption to the table we use ____________
a) <caption>
b) <thead>
c) <th>
d) <tr>
View Answer

Answer: a
Explanation: For adding caption to the table we use <caption> tag. It should be used just below the <table> tag.

Syntax is 
<table> 
<caption> Savings </caption> 
<tr> <th> saving </th><th>loss</th> </tr> 
<tr><td>$12</td>$45<td></td> </tr> 
</table>.

<thead> tag contains the group of header. <tr> is used to indicate start of every row i.e. it stands for table row. The header information is present in <th> tag.

advertisement

7. border-spacing is given in _____________
a) pixels
b) cm
c) mm
d) inch
View Answer

Answer: a
Explanation: border-spacing and border-collapse are the two properties by which one can set the border and its styling in a table. We give its value in pixels.

advertisement
 table { border-collapse: collapse; border-spacing: 14px } th, td{ border: 12 px solid red; padding: 20px 13px; }

8. Borders can’t be applied on ________________
a) <th>
b) <td>
c) <tr>
d) <thead>
View Answer

Answer: c
Explanation: Borders can’t be applied on <tr> elements. It can’t be applied on table structural elements. For setting borders with <tr> element, border-collapse property should be set to collapse.

Syntax is 
table {border-collapse: collapse;} 
th, td{border-bottom: 2px dotted red; } 
tfoot tr:last-child td{border-bottom: 9 px;}

9. Which attribute defines numbers of columns in a group?
a) width=multi-length[CN].
b) span=number[CN].
c) scope=scope-name[CN].
d) headers=idrefs[CS].
View Answer

Answer: b
Explanation: span=number[CN] attribute’s value must be an integer and greater than 0. It specifies the number of columns in a group. When span attribute is not in use, colgroup defines a single column group containing one column. width=multi-length[CN] specifies default width of for every column. scope=scope-name[CN] specifies set of data cells for which going header cell gives header information. The headers=idrefs[CN] provides list of header cells that gives header information.

10. Which of the following does not specify a column width?
a) Fixed
b) Percentage
c) Proportional
d) Pixels
View Answer

Answer: d
Explanation: We can specify column width in three ways i.e. Percentage, Fixed, Proportional. Fixed width is given in pixels. Percentage specification is the percentage of horizontal space availability in the table. The proportional specification is the portions of fixed horizontal space required for the table.

11. Scope attribute can’t have the value __________
a) row
b) rowgroup
c) col
d) <head>
View Answer

Answer: d
Explanation: scope attribute defines a set of data cell. It is used in place of headers. This attribute can have one of the value among rowgroup, row, colgroup, col, rowgroup, and colgroup provides information of header cell of the corresponding row and column groups.

12. Which of the following is not the value for frame attribute?
a) above
b) void
c) none
d) box
View Answer

Answer: c
Explanation: Frame attribute gives information about which sides of the frame surrounding that table will be visible. The values that this attribute can take are lhs, rhs, box, border, vsides, hsides, below, above, void.

13. Which of the following is not the value for rules attribute?
a) vsides
b) rows
c) all
d) groups
View Answer

Answer: a
Explanation: The rules which will appear between cells of the table is specified by this attribute. It can take the values groups, none, rows, all and cols. None is the default value, rows are for appearance between rows only and cols is for columns only.

14. Which of the following is not the value for align attribute?
a) justify
b) char
c) middle
d) left
View Answer

Answer: c
Explanation: align attribute is the alignment of data and for justification of text in the cell. It can take the values left, right, justify, center, char. Justify is for double justifying the text, char is for aligning text around a particular character.

15. valign attribute does not take the value __________________
a) justify
b) middle
c) baseline
d) bottom
View Answer

Answer: a
Explanation: valign attribute is for specifying the vertical position of the data in a cell. It can take the values middle, top, baseline, bottom, Top is for the top of the cell’s data, middle is for the centered data, bottom is for the bottom of the cell, first text line occurs on the baseline which is common to all the cells.

Sanfoundry Global Education & Learning Series – HTML.

To practice all areas of HTML, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.