Working with Tables in HTML Class 10 Computer Science Exam Questions

Exam Questions Class 10

Please refer to Working with Tables in HTML Class 10 Computer Science Exam Questions provided below. These questions and answers for Class 10 Computer Science have been designed based on the past trend of questions and important topics in your class 10 Computer Science books. You should go through all Class 10 Computer Science Important Questions provided by our teachers which will help you to get more marks in upcoming exams.

Class 10 Computer Science Exam Questions Working with Tables in HTML

Class 10 Computer Science students should read and understand the important questions and answers provided below for Working with Tables in HTML which will help them to understand all important and difficult topics.

Short Answer Type Questions

Question: Write HTML code to display a table with border of 5px. 
Answer: <HTML><BODY>
<TABLE border = “5”>
<TR><TD>1</TD></TR>
<TR><TD>2</TD></TR>
</TABLE>
</BODY></HTML>

Question: Name the attributes of <TABLE> tag, which are used for specifying its dimensions in a web page.
Answer: width and height attributes of <TABLE> tag, which are used for specifying its dimensions in a web page. width and height are specified in terms of pixel or percentage of the browser window.

Question: Differentiate between cellpadding and cellspacing in HTML table.
Answer: Differences between cellpadding and cellspacing are as follows  image

Question: Explain the width attribute of <TABLE> tag.
Answer: The width attribute is used to set the absolute width of the table. The values in width attribute can be either in pixel or in percentage of the browser window.
e.g.
<TABLE width = “150”>
<TR><TD>Cell1</TD><TD>Cell2</TD></TR>
<TR><TD>Cell3</TD><TD>Cell4</TD></TR>
</TABLE>

Question: What is table? Name the basic commands for creating a table.
Answer: Tables are made up of rows and columns. In HTML,tables are used to display tabular data in web pages. The basic commands for creating tables are as follows:
Table tag <TABLE> </TABLE>
Row tag <TR> </TR>
Cell tag <TD> </TD>, <TH> </TH>
Caption tag <CAPTION> </CAPTION>

Question: Name the attributes used for following.
(i) Setting the cell width
(ii) Setting cell’s background image
(iii) Setting cell’s background color
(iv) Changing the cell span
Answer: (i) width
(ii) background
(iii) bgcolor
(iv) rowspan and colspan

Question: What is the function of summary attribute?
Answer: summary attribute of <TABLE> tag is used to provide the detailed information about a table. It enables a user to know the type of information that a table contains. It is useful to provide access to non-visual browsers, which are used by users with visual impairment.
e.g. <TABLE summary=”text”>

Question: What is data cell? Name the <TABLE> tag, which is used as data cell.
Answer: The data cell defines a cell of a table that contains data.
The table data cell is coded with <TD> tag of <TABLE> tag. Here, TD stands for Table Data. The content in the table data cell is normal and left-aligned by default.

Question: Name the attributes that are used to do the following in HTML.
(i)Merge two or more rows
(ii) Change the background color of the cells in a table
(iii) Vertically align cell content
(iv)Merge two or more columns
Answer: (i) rowspan (ii) bgcolor (iii) valign (iv) colspan

Question: Which attributes can you use with <TABLE> tag but not with <TR> tag?
Answer: summary, rules, frame, border, cellpadding, cellspacing,height, width and bordercolor are the attributes that you can use with <TABLE> tag but not with <TR> tag.

Question: Mr. Ayush, Sports Captain of the school, has to display sequence of events of the upcoming Annual Sports Day on the school website. Help him in writing HTML code to create a table in HTML as shown in the given screenshot. 

Answer: <HTML>
<BODY>
<TABLE border = “1”>
<TR>
<TH colspan =”3″ align =”center”> ANNUAL
SPORTS DAY-SEQUENCE OF EVENTS</TH>
</TR>
<TR align =”center”>
<TD>8:00 AM – 9:00 AM</TD>
<TD>9:00 AM-1:00 PM</TD>
<TD>1:00 PM-2:00 PM</TD>
</TR>
<TR align =”center”>
<TD>CULTURAL EVENTS</TD>
<TD>TRACK EVENTS</TD>
<TD>PRIZE DISTRIBUTION</TD>
</TR>
</TABLE>
</BODY>
</HTML>

Question: Define the <TH> and <TR> tags. Are these two tags similar? If yes, how?
Answer: <TH> stands for Table Header. It is used to give headings to the various columns in our table. <TR> stands for Table Row. It is used to create a row in a table.
<TH> and <TR> tags are not similar. <TH> tag is similar to <TD> tag. Since, <TH> tag also defines a data cell, which is taken as heading to the columns and
the data is bold faced.

Question: What is header cell? Name the <TABLE> tag,which is used as header cell.
Answer: The header cell specifies the header of the table and displays the content of a table in heading style. The content in the table header cell is rendered in bold and centered horizontally within the cell. The table header cell is coded with <TH> tag.

Question: Saroj, a student of Class X, wants to represent a table in web page but she is unaware about the table tag. Explain her the role of <TH>, <TR> and <TD> tags. Write HTML code of a table and show the use of <TH>, <TR> and <TD> tags.
Answer: <TR> tag defines the table row which is used to create a new row of data in a table.
<TH> tag defines the table header which is used for specifying a table’s header.
<TD> tag defines the table data which is used to specify a cell or table data within a table.
e.g. <TABLE>
<TR>
<TH>Name</TH>
<TH>Subject</TH>
</TR>
<TR>
<TD>Rahul</TD>
<TD>Mathematics</TD>
</TR>
<TR>
<TD>Muskan</TD>
<TD>Science</TD>
</TR>
</TABLE>

Question: What are the roles of rowspan and colspan attributes? Explain with suitable HTML example.
Answer: colspan attribute allows the user to stretch a cell to span multiple columns (merge two or more columns). rowspan attribute is used to span multiple rows (merge two or more rows).
e.g. <TABLE border = ‘1’>
<TR>
<TD> Row-1 Column-1 </TD>
<TD colspan = “2”>Row-1 Column-2 and 3
                                                              </TD>
<TD rowspan = “2”>Row-1 and 2 Column-4
                                                                  </TD> </TR>
<TR>
<TD> Row-2 Column-1 </TD>
<TD> Row-2 Column-2 </TD>
<TD> Row-2 Column-3 </TD>
</TR>
</TABLE>

Long Answer Type Questions

Question: Write the HTML code to create the exact table which is given below. 

Answer: The HTML code is 
<HTML>
<BODY>
<TABLE border=”3″>
<TR align=”center” valign=”middle”>
<TH> ADMNO </TH>
<TH> SNAME </TH>
<TH> NAME </TH>
<TH> DOB </TH>
</TR>
<TR align=”left” valign=”middle”>
<TD> 1110 </TD>
<TD> MANJIT </TD>
<TD> RANJIT </TD>
<TD> 4-MAR-1998 </TD>
</TR>
</TABLE>
</BODY>
</HTML>

Question: Observe the following table and write the HTML code to generate it. 

Answer: The HTML code is 
<HTML>
<BODY>
<TABLE cellpadding = “10” cellspacing=”0″
border=”1″>
<TR align = “center”>
<TH>Period1</TH>
<TH>Period2</TH>
</TR>
<TR align = “center”>
<TD>Math</TD>
<TD>Science</TD>
</TR>
<TR align=”center”>
<TD>English</TD>
<TD>SST</TD>
</TR>
<TR align=”center”>
<TD>Science</TD>
<TD>SST</TD>
</TR>
</TABLE>
</BODY>
</HTML>

Question: What is the use of <TR> tag in an HTML table?
Give a suitable example.
Answer: The <TR> tag creates a table row in an HTML table. A table must have atleast one row and also, it can have as many table rows as you want. A table row is divided into table cells. A table must have atleast one table cell per table row.
e.g.
<HTML>
<HEAD><TITLE> TR Tag </TITLE></HEAD>
<BODY>
<TABLE border = “1” cellpadding =”3″>
<TR>
<TH> Head 1 </TH>
<TH> Head 2 </TH>
<TH> Head 3 </TH>
</TR>
<TR>
<TD> A </TD>
<TD> B </TD>
<TD> C </TD>
</TR>
<TR>
<TD> D </TD>
<TD> E </TD>
<TD> F </TD>
</TR>
</TABLE>
</BODY>
</HTML>
Output   

Question: Write the HTML code to generate the following table on a web page with the contents and alignment exactly as shown below.  

Answer:The HTML code is
<HTML>
<BODY>
<TABLE border=”1″ width = “400”>
<TR align=”right”>
<TH>MOVID</TH>
<TH>MOVNAME</TH>
<TH>ACTORS</TH>
</TR>
<TR align=”left”>
<TD>M001</TD>
<TD>HIT FACTORY</TD>
<TD>4</TD>
</TR>
</TABLE>
</BODY>
</HTML>

Question: Write names of two attributes each for the following tags. 
(i) <HR>
(ii) <BODY>
(iii) <IMG>
(iv) <TABLE>
(v) <A>
Answer: 

Question: Write the HTML code to generate the following table with the contents exactly in the same format as shown within the table. 

Answer: The HTML code is
<HTML><BODY>
<TABLE border=”1″>
<TR>
<TH colspan=”4″ align=”center”>
Shopping Mall</TH>
</TR>
<TR align = “center”>
<TD>Floor</TD>
<TD>No. of Toy<BR>Shops</TD>
<TD>No. of Food<BR>Shops</TD>
<TD>No. of Sports<BR>Shops</TD>
</TR>
</TABLE>
</BODY>
</HTML>

Question: Observe the following table and write the HTMLcode to generate it.

Answer: The HTML code is
<HTML>
<BODY> <BASEFONT face=”cambria”>
<TABLE border=”1″ bordercolor=”black”
cellspacing=”0″ width=”320″>
<CAPTION> Activities </CAPTION>
<TR>
<TD rowspan=”3″> Sr School </TD>
<TD> Maths Club </TD>
</TR>
<TR>
<TD> Robotics Club </TD>
</TR>
<TR>
<TD> Photography </TD>
</TR>
<TR>
<TD rowspan=”3″>Middle School </TD>
<TD> Gymnastic </TD>
</TR>
<TR>
<TD> Yoga </TD>
</TR>
<TR>
<TD> Computer Club </TD>
</TR>
<TR>
<TD rowspan=”3″> Primary School </TD>
<TD> Dance </TD>
</TR>
<TR>
<TD> Vocal Music </TD>
</TR>
<TR>
<TD> Swimming </TD>
</TR>
</TABLE>
</BODY>
</HTML>

Question: Write an HTML code to print the following table 

Note ♦ Background color of a table is pink.
 ♦ Caption of a table is in red color.
Answer: The HTML code is
<HTML>
<HEAD>
<TITLE>Student</TITLE>
</HEAD>
<BODY>
<TABLE border=”4″ bgcolor=”pink”
height=”50%” width=”70%”align=”center”>
<CAPTION>
<B>
<FONT size=”4″ color=”red”>
Student Data
</FONT>
</B>
</CAPTION>
<TR>
<TH>Student Name</TH>
<TH>Roll No</TH>
<TH>Address</TH>
<TH>Marks</TH>
</TR>
<TR>
<TD>Amrita</TD>
<TD>1</TD>
<TD>Shastri Nagar</TD>
<TD>483</TD>
</TR>
<TR>
<TD>Taruna </TD>
<TD>2</TD>
<TD>T.P Nagar</TD>
<TD>418</TD>
</TR>
<TR>
<TD>Priyanka</TD>
<TD>3</TD>
<TD>Saket</TD>
<TD>489</TD>
</TR>
</TABLE>
</BODY>
</HTML>

Question: Observe the following web page and write HTML code to generate it.  

Note The following points while generating the web page:
 ♦ Background color of page is yellow.
 ♦ Link color is black and visited link color is green.
 ♦ Font style for the page is arial.
 ♦ Heading of the page is maroon.
 ♦ Image used is mainrhino.jpg.
 ♦ Table border is 2px.
Answer: The HTML code is <HTML>
<BODY bgcolor=”yellow” link=”black” vlink=”green”>
<BASEFONT face=”arial”>
<H1 align=”center”>
<FONT color=”maroon”>INDIAN
RHINOCEROS</FONT></H1>
<IMG src=”mainrhino.jpg” align=”right” height=”100″
width=”110″>
The Indian rhinoceros lives primarily in northern India
and Nepal. These massive beasts have some noticeable
physical differences from their African relatives. Their
segmented hide looks like a formidable coat of natural
body armour. It functions a bit like one also. Flexible skin
between the thicker hide “plates” allows them to shift as
the rhinoceros moves.
<BR><BR>
Other Endangered Animals:
<UL>
<LI>
Whooping Crane
</LI>
<LI>
White Rhino
</LI>
<LI>
Sumatran Rhino
</LI>
<LI>
Toucan
</LI>
</UL>
<TABLE border=”2″ align=”center”>
<CAPTION>Fast Facts</CAPTION>
<TR><TD>Type</TD>
<TD>Mammal</TD>
</TR>
<TR>
<TD>Diet</TD>
<TD>Herbivore</TD>
</TR>
<TR>
<TD>Average life span in the wild</TD>
<TD>40 years</TD>
</TR>
<TR>
<TD>Size</TD>
<TD>Length 12.5 ft; Height up to 6 ft</TD>
</TR>
<TR>
<TD>Weight</TD>
<TD>4,400 lbs (2,000 kg)</TD>
</TR>
</TABLE>
<BR>
For more Details
</BODY>
</HTML>

Question: Write the HTML code to generate the following web page.

NoteThe following points while generating the web page:
 ♦ Link color is green, active link color is blue and visited link color is red.
 ♦ Title of the page is “Eat healthy, live healthy”.
 ♦ Heading of the page is maroon.
 ♦ Image used is “Restaurant.jpg”.
 ♦ Caption of table is blue.
 ♦ Table border is blue and of size 2. 
Answer: The HTML code is
<HTML>
<HEAD>
<TITLE>Eat healthy, live healthy</TITLE>
</HEAD>
<BODY link=”green” alink=”blue” vlink=”red”>
<CENTER>
<H1>
<FONT color=”maroon”>KHAO PIYO
RESTAURANT </FONT>
</H1>
</CENTER>
<IMG src=”Restaurant.jpg”
align=”right”height =”255″ width=”250″>
Collect Information for
<UL>
<LI> Menus </LI>
<LI> Reservation </LI>
<LI> Catering </LI>
<LI></LI>
</UL>
<CENTER>
<TABLE border=”2″ bordercolor=”blue”>
<FONT color=”blue”>
<CAPTION> Menus available are </CAPTION>
</FONT>
<TR>
<TD> 1 </TD> <TD> INDIAN </TD>
</TR>
<TR>
<TD> 2 </TD> <TD> ITALIAN </TD>
</TR>
<TR>
<TD> 3 </TD> <TD> CONTINENTAL </TD>
</TR>
<TR>
<TD> 4 </TD> <TD> THAI </TD>
</TR>
</TABLE>
</CENTER>
<BR>
For further queries and reservation
Contact Us
</BODY></HTML>

Question: Carefully study the web page given below. Identify 8 tags (structural as well as formatting tags) that have been utilised in creating this web page and write the usage of each of them. 

Answer: (i) <TITLE> to specify the title of the web page.
(ii) <BODY> contains all the content that is to be displayed on web page and all the various formatting and structural tags.
(iii) <UL> used to create an unordered list.
(iv) <LI> to specify the various list items in a list.
(v) <CAPTION> to provide caption to the table.
(vi) <TABLE> used to create table in HTML document.
(vii) <TR> stands for table row, used to create a table row.
(viii) <TD> stands for table data, helps to create cells in HTML table.

Working with Tables in HTML Class 10 Computer Science Exam Questions

We hope you liked the above provided Working with Tables in HTML Class 10 Computer Science Exam Questions. If you have any further questions please put them in the comments section below so that our teachers can provide you an answer.