Multiple-Choice Questions On
Class 9
Advanced Table Techniques
1.
Which HTML attribute is used to
merge table cells horizontally?
o A)
rowspan
o B)
colspan
o C)
align
o D)
valign
o Answer: B)
colspan
2.
How can you merge table cells
vertically?
o A)
Use colspan
o B)
Use rowspan
o C)
Use align
o D)
Use valign
o Answer: B)
rowspan
3.
What is the default border style
for an HTML table if not specified?
o A)
Solid
o B)
Dashed
o C)
Dotted
o D)
None
o Answer: D)
None
4.
Which HTML tag is used to create a
table header?
o A)
<header>
o B)
<thead>
o C)
<tfoot>
o D)
<th>
o Answer: D)
<th>
5.
Which CSS property can be used to
add space between the cell content and the cell border?
o A)
border-spacing
o B)
padding
o C)
margin
o D)
border-width
o Answer: B)
padding
6.
What is the purpose of the
<tfoot> tag in an HTML table?
o A)
To define the table body
o B)
To group table columns
o C)
To create a footer for the table
o D)
To define table rows
o Answer: C)
To create a footer for the table
7.
How can you apply a border to an
HTML table?
o A)
Use the border attribute in the <table> tag
o B)
Use CSS border property
o C)
Use the cellborder attribute in the <table> tag
o D)
Use the border attribute in the <td> tag
o Answer: B)
Use CSS border property
8.
Which CSS property can be used to
set the background color of table rows?
o A)
background
o B)
background-color
o C)
row-color
o D)
cell-background
o Answer: B)
background-color
9.
Which HTML element can be used to
create a table within another table?
o A)
<inner-table>
o B)
<nested-table>
o C)
<table>
o D)
<tr>
o Answer: C)
<table>
10.
What does the border-collapse
property do in CSS for tables?
o A)
Specifies the border style
o B)
Collapses table borders into a single border
o C)
Adds space between borders
o D)
Sets the border color
o Answer: B)
Collapses table borders into a single border
11.
In a dynamically generated table
with JavaScript, which method is used to add a new row?
o A)
insertRow()
o B)
appendChild()
o C)
createElement()
o D)
addRow()
o Answer: A)
insertRow()
12.
Which HTML tag is used to define a
table row?
o A)
<tr>
o B)
<td>
o C)
<th>
o D)
<table>
o Answer: A)
<tr>
13.
What does the colspan attribute do
in a table cell?
o A)
Specifies the number of rows a cell should span
o B)
Specifies the number of columns a cell should span
o C)
Adds padding to the cell
o D)
Sets the color of the cell border
o Answer: B)
Specifies the number of columns a cell should span
14.
Which property is used to apply a
shadow effect to table cells?
o A)
box-shadow
o B)
text-shadow
o C)
shadow
o D)
border-shadow
o Answer: A)
box-shadow
15.
What is the correct HTML structure
to define a table header with multiple columns?
o A)
<tr><th colspan="2">Header</th></tr>
o B)
<tr><th rowspan="2">Header</th></tr>
o C)
<thead><tr><th>Header</th></tr></thead>
o D)
<header><th>Header</th></header>
o Answer: A)
<tr><th colspan="2">Header</th></tr>
16.
How do you add space between the
cells of an HTML table using CSS?
o A)
cell-spacing
o B)
border-spacing
o C)
margin
o D)
padding
o Answer: B)
border-spacing
17.
Which attribute of the
<table> tag controls the table's border width?
o A)
border-width
o B)
border
o C)
border-style
o D)
border-spacing
o Answer: B)
border
18.
In which HTML tag do you specify
the title for a column in a table?
o A)
<td>
o B)
<tr>
o C)
<th>
o D)
<caption>
o Answer: C)
<th>
19.
To make the header row of a table
stick at the top when scrolling, which CSS property can be used?
o A)
position: sticky;
o B)
overflow: auto;
o C)
display: fixed;
o D)
position: fixed;
o Answer: A)
position: sticky;
20.
Which HTML tag is used to group a
set of table columns?
o A)
<tfoot>
o B)
<tbody>
o C)
<colgroup>
o D)
<tr>
o Answer: C)
<colgroup>
21.
What does the rowspan attribute do
in a table cell?
o A)
Merges cells horizontally
o B)
Specifies the number of rows a cell should span
o C)
Sets the cell’s alignment
o D)
Adds a border to the cell
o Answer: B)
Specifies the number of rows a cell should span
22.
Which CSS property is used to apply
a background image to a table?
o A)
background
o B)
background-color
o C)
background-image
o D)
table-background
o Answer: C)
background-image
23.
In an HTML table, which element is
used to specify the footer of the table?
o A)
<tfoot>
o B)
<header>
o C)
<tfoot>
o D)
<tfoot>
o Answer: A)
<tfoot>
24.
How can you make a table cell's
content span multiple columns in HTML?
o A)
Use rowspan attribute
o B)
Use colspan attribute
o C)
Use span attribute
o D)
Use align attribute
o Answer: B)
Use colspan attribute
25.
Which CSS property is used to set
the space between the border and the content of table cells?
o A)
border-spacing
o B)
padding
o C)
margin
o D)
border-width
o Answer: B)
padding
26.
How do you specify different styles
for odd and even rows in a table using CSS?
o A)
Use :nth-child(even) and :nth-child(odd) pseudo-classes
o B)
Use :first-child and :last-child pseudo-classes
o C)
Use :even and :odd pseudo-classes
o D)
Use :row(odd) and :row(even) pseudo-classes
o Answer: A)
Use :nth-child(even) and :nth-child(odd) pseudo-classes
27.
Which HTML element is used to
define a single cell within a table row?
o A)
<th>
o B)
<tr>
o C)
<td>
o D)
<caption>
o Answer: C)
<td>
28.
What does the scope attribute in
the <th> tag define?
o A)
The type of border to apply
o B)
The header's position
o C)
The cells the header applies to (e.g., row, column, or both)
o D)
The background color of the header
o Answer: C)
The cells the header applies to (e.g., row, column, or both)
29.
Which CSS property can be used to
control the width of a table column?
o A)
column-width
o B)
width
o C)
table-width
o D)
cell-width
o Answer: B)
width
30.
How can you add a caption to an
HTML table?
o A)
<caption> tag within the <thead>
o B)
<caption> tag within the <tfoot>
o C)
<caption> tag within the <table>
o D)
<header> tag within the <table>
o Answer: C)
<caption> tag within the <table>
31.
Which attribute is used in the
<table> tag to set the spacing between the table cells?
o A)
cell-spacing
o B)
border-spacing
o C)
spacing
o D)
cell-padding
o Answer: B)
border-spacing
32.
Which CSS property would you use to
set the width of a table's border?
o A)
border-width
o B)
border-style
o C)
border-color
o D)
border-spacing
o Answer: A)
border-width
33.
How do you define a table cell that
spans across multiple columns using HTML?
o A)
<td colspan="number">
o B)
<td span="number">
o C)
<td width="number">
o D)
<td row-span="number">
o Answer: A)
<td colspan="number">
34.
Which CSS property allows you to
add a border around the entire table?
o A)
border
o B)
border-collapse
o C)
border-color
o D)
border-style
o Answer: A)
border
35.
To apply a different background
color to every other row in a table, which CSS pseudo-class is commonly used?
o A)
:nth-of-type(2n)
o B)
:nth-child(even)
o C)
:nth-of-type(odd)
o D)
:nth-child(odd)
o Answer: B)
:nth-child(even)
36.
Which HTML element is used to
create a table caption?
o A)
<header>
o B)
<legend>
o C)
<caption>
o D)
<title>
o Answer: C)
<caption>
37.
In CSS, how can you ensure that
table borders are collapsed into a single border?
o A)
border-collapse: separate;
o B)
border-collapse: collapse;
o C)
border-spacing: collapse;
o D)
border-style: collapse;
o Answer: B)
border-collapse: collapse;
38.
What HTML attribute allows you to
set the alignment of content within a table cell?
o A)
align
o B)
valign
o C)
text-align
o D)
cell-align
o Answer: A)
align
39.
How can you make sure that a table
cell does not wrap text but instead expands to fit the content?
o A)
white-space: nowrap;
o B)
overflow: hidden;
o C)
text-wrap: none;
o D)
word-wrap: break-word;
o Answer: A)
white-space: nowrap;
40.
Which CSS property is used to set
the text alignment inside table headers and cells?
o A)
text-align
o B)
align
o C)
cell-align
o D)
vertical-align
o Answer: A)
text-align
41.
Which CSS pseudo-class can be used
to style the first row of a table differently?
o A)
:first-of-type
o B)
:first-child
o C)
:nth-of-type(1)
o D)
:nth-child(1)
o Answer: B)
:first-child
42.
What HTML element should be used to
group the table's header content?
o A)
<thead>
o B)
<tbody>
o C)
<tfoot>
o D)
<tr>
o Answer: A)
<thead>
43.
To apply different styles to table
headers and table data cells, which HTML tags should you target with CSS?
o A)
<thead> and <tbody>
o B)
<th> and <td>
o C)
<tr> and <th>
o D)
<table> and <caption>
o Answer: B)
<th> and <td>
44.
Which HTML attribute is used to
specify a table's column width?
o A)
col-width
o B)
width
o C)
colspan
o D)
style
o Answer: B)
width
45.
How can you apply a border to a
specific table cell only using CSS?
o A)
Use border property in the CSS for that specific <td> or <th>
o B)
Use border attribute directly in the <td> or <th>
o C)
Use cell-border property
o D)
Apply border in the parent <tr>
o Answer: A)
Use border property in the CSS for that specific <td> or <th>
46.
Which CSS property allows you to
set the spacing between the borders of adjacent table cells?
o A)
border-spacing
o B)
cell-spacing
o C)
border-padding
o D)
spacing
o Answer: A)
border-spacing
47.
What HTML tag should be used to
create a table footer?
o A)
<tfoot>
o B)
<tfoot>
o C)
<foot>
o D)
<footer>
o Answer: A)
<tfoot>
48.
How can you make sure a table’s
width adjusts to fit its content using CSS?
o A)
width: 100%;
o B)
width: auto;
o C)
max-width: 100%;
o D)
overflow: auto;
o Answer: B)
width: auto;
49.
Which CSS property is used to set
the border style of a table?
o A)
border-style
o B)
border-width
o C)
border-color
o D)
border-type
o Answer: A)
border-style
50.
Which attribute of the
<table> tag can be used to merge cells horizontally?
o A)
colspan
o B)
rowspan
o C)
merge
o D)
span
o Answer: A)
colspan
51.
In a table, how can you apply
different styles to odd rows?
o A)
Use :nth-child(odd) in CSS
o B)
Use :nth-of-type(odd) in CSS
o C)
Use :even-child in CSS
o D)
Use :first-child in CSS
o Answer: A)
Use :nth-child(odd) in CSS
52.
How do you set the alignment of
text inside a table cell using CSS?
o A)
text-align
o B)
vertical-align
o C)
align
o D)
cell-align
o Answer: A)
text-align
53.
Which CSS property is used to hide
the table border while keeping the table's structure?
o A)
border-color: transparent;
o B)
border-width: 0;
o C)
border-style: none;
o D)
border-spacing: 0;
o Answer: B)
border-width: 0;
54.
What does the rowspan attribute do
in a table?
o A)
Merges cells horizontally
o B)
Specifies the number of columns a cell should span
o C)
Specifies the number of rows a cell should span
o D)
Sets the border width of the cell
o Answer: C)
Specifies the number of rows a cell should span
55.
Which pseudo-class is used to style
the last row of a table?
o A)
:last-child
o B)
:last-of-type
o C)
:nth-last-child(1)
o D)
:nth-last-of-type(1)
o Answer: A)
:last-child
56.
Which CSS property controls the
alignment of a table cell’s content vertically?
o A)
vertical-align
o B)
text-align
o C)
align-items
o D)
justify-content
o Answer: A)
vertical-align
57.
To change the background color of
every third row in a table using CSS, which pseudo-class would you use?
o A)
:nth-of-type(3n)
o B)
:nth-child(3n)
o C)
:nth-last-child(3n)
o D)
:nth-of-type(even)
o Answer: B)
:nth-child(3n)
58.
Which CSS property would you use to
add a space around the table content?
o A)
padding
o B)
margin
o C)
border-spacing
o D)
cell-spacing
o Answer: A)
padding
59.
In HTML, how can you create a table
with alternating row colors for better readability?
o A)
Use CSS :nth-child() pseudo-class for alternating row colors
o B)
Use the bgcolor attribute on each <tr>
o C)
Use inline styles within each <tr>
o D)
Use the background attribute on the <table>
o Answer: A)
Use CSS :nth-child() pseudo-class for alternating row colors
60.
Which CSS property is used to
control the appearance of the table borders?
o A)
border-style
o B)
border-width
o C)
border-color
o D)
border
o Answer: D)
border
