0% found this document useful (0 votes)
65 views

HTML Previous Year Questions

Uploaded by

ishika.rathoree
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

HTML Previous Year Questions

Uploaded by

ishika.rathoree
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

PREVIOUS YEARS HTML QUESTIONS FROM EXAM POINT OF VIEW

HTML (HyperText Markup Language)


Very Short Answer Type Questions [1 Mark each]
Question 1. HTML is a markup language. Expand the term HTML. CBSE 2002
Answer: HyperText Markup Language.
Question 2. Give examples of a container element in HTML. CBSE 2009
Answer: <HEAD>, <TITLE>, <BODY>.
Question 3. Give the examples of an empty element in HTML. CBSE 2010, 09
Answer: <BR>, <HR>
Question 4. Write the extension of HTML code file. CBSE 2005
Answer: .html or .htm
Question 5. What is the method of viewing the source code of the current page in the Web browser?
Answer: Right click on the Web page and then select View Source from the context menu.
Question 6. While writing HTML code, how do you find out how your Web page would look like?
CBSE 2007
Answer: For this, open the HTML code file in a Web browser.
Question 7. Write HTML code to set the image ‘Pen. jpg’ stored in ‘My Pictures’ folder in C: as the
background of your Web page. CBSE 2007
Answer: The HTML code is <BODY background=“C:\My Pictures \Pen.jpg”>.
Question 8. Identify the error(s) in the following HTML code. Also, write the correct code. CBSE
2008
<BODY color=“red” background =“school.j pg”>
Answer: The error in the code is that in place of color attribute there should be bgcolor.
The correct code is
<BODY bgcolor =“red” background =“school.jpg”>
Question 9. Write one basic difference between bgcolor and background attributes.
Answer: The bgcolor attribute is used for coloring the background of the document while background
attribute specifies a background image for a document.
Question 10. Name two common graphic files formats that most browser recognise.
Answer: The two common graphic file formats are: .gif and .jpg.
Question 11. What is the use of width attribute in HTML?
Answer: Width attribute specifies the width of a horizontal line in pixels or percent. Its default value is
100%.
Question 12. What do you understand by option alink used with <BODY> tag?
Answer: alink attribute defines the color of the link as it is being clicked on the Web page. The default
color of alink is red.
Question 13. What do you understand by option vlink used with <BODY> tag?
Answer: vlink attribute defines the color of a link after it has been visited. The default color of vlink
attribute is purple.
Question 14. Explain the following statement:
<BODY bgcolor=“yellow” text =“red” vlink=“blue”>
Answer: The code will set the Web page background color as yellow, text color as red and visited link
color as blue.
Question 15. How the font size of a single line on a Web page be changed?
Answer: The font size of a single line can be changed by using the following HTML code:
<FONT size =+1> This is a HTML text </FONT>.
Question 16. What is the use of <FONT> tag in HTML code? Write any two options used with this
tag. CBSE
Answer: The <FONT> tag is used to change the size, color and type face of the text on HTML page. It
uses attributes such as size, face etc.

Question 17. Identify the errors and write the correct HTML code
1) <BODY background = ‘‘red”> 2. <FONT type =‘‘arial ”>
Answer: 1) <BODY bgcolor=“red”> 2) <FONT face=“arial”>
uestion 18. What is the method of using comment line in the HTML code?
Answer: In HTML code, the comment line is declared as <!–Any text –>
Question 19. Which heading element gives the most prominent headings?
Answer: <H1>
Question 20. Which tag is used to insert heading of third level on a Web page?
Answer: <H3>
Question 21. What is the purpose of using the tags <H1>…<H6>? or
What is the method of using headings in HTML? or
Write the difference between <H1> and <H6> heading tags.
Answer: <HTML> provides six levels of headings. <H1> is the largest heading level while <H6> is the
smallest heading level. These headings help us in obtaining a uniform look and feel for the document.
Question 22. How can anyone insert horizontal line in a Webpage?
Answer: Using <HR> tag, anyone can insert horizontal line in a Web page.
Question 23. Explain the following statement:
<HR size=“5” align=”right” width=“60”>
Answer: The given HTML code produces a horizontal rule with size 5, aligning right on page and of
width 60.
Question 24. Write the HTML code to display horizontal line of red color.
Answer: <HR color = “red”>
Question 25. Write the expansions of the following tags used in HTML.
1) <BR> 2) <I> 3) <HR> 4) <U>
Answer: <BR> — Break line <I> — Italic <HR> – Horizontal Rule <U> —
Underline
Question 26. Write the expansions of the following tags used in HTML. 1) <A> 2) <!>
Answer: <A> – Anchor tag <!> – Comment tag
Question 27. Which HTML tag is used to insert an image in a page? Write an option used with this
tag.
Answer: The <IMG> tag is used to insert an image in a page. This tag uses the options like src, alt etc.
Question 28. What do you mean by src?
Answer: The src is an attribute of <IMG> tag. It gives the URL of the image document.
Question 29. Write the full form of the following tags: <LI> <IMG>
Answer: <LI>-List item <IMG>-Image
Question 30. What are the different forms of list used in HTML? Name any two. CBSE 2004
Answer: The different forms of list are ordered list and unordered list.
Question 31. What are two basic tags in HTML lists?
Answer: <OL> and <UL>
Question 32. What does a <LI> create when used in an unordered list?
Answer: <LI> creates bulleted points for each list item.
Question 33. Write the expansions of the following tags. <P> <UL> <OL>
<B>
Answer: <P>-Paragraph <UL>-Unordered list <0>-Ordered list <B >-Bold
Question 34. Find error(s) in the following HTML code segment. Rewrite the correct code. CBSE
2007
<UL style = square>
<LI> Water Bottles
<LI> Lunch Box
<LI> Handkerchief
</UL>
Answer: There should be type instead of style. So, correct line is <UL type =“square”>
Short Answer Type Questions [2 & 3 Marks each]
Question 1. What is the purpose of using HTML tags and attributes for Web designing?
Answer: HTML (HyperText Markup Language) is used to create Web pages. It designs the basic layout
and formatting of Web pages by using tags and attributes.
The tag’s name tells the tag’s purpose and the attributes that follow the tag name give the additional
information of the Web browser.
Question 2. Differentiate between container and empty elements used in HTML.or
Distinguish between container and empty tags. or
Sriram software solution has used different tags in its Website some are empty while majority are
container. Give the detailed difference between container and empty elements.
Answer: Container elements HTML container elements require a starting as well as an ending tags.
e-g <HTML>, <HEAD>, <BODY>.
Empty elements HTML empty elements require just a starting tag and not an ending tag.
e.g.<IMG> , <BR> , <HR>.
Question 3. Find the error(s) in the following code and underline those errors.
<HTML>
<HEAD>
<TITLE> Example </HEAD>
</TITLE>
<BODY> ........... </BODY>
</HTML>
Question 4. What is the use of <BODY> tag in HTML code? Write any two attributes used with
this tag.
or
What does <BODY> tag in HTML contain? Write any two attributes used with this tag.
Answer: The <BODY> tag encloses the main part of the document. It contains all the contents of a
document. Various markup elements are allowed within the body to indicate heading, paragraphs, lists,
hypertext links, images and so on. The <BODY> tag uses various attributes such as background, bgcolor
etc.
Question 5. Write the HTML code to set the bgcolor as pink, heading level 2, text This is pink
background’ as black and topmargin 60.
Answer:
<HTML>
<BODY bgcolor = "pink” topmargin=“60” text= “black”>
<H2>This is pink background</H2>
</BODY >
</HTML>
Question 6. Write the HTML code to create a paragraph whose text color is blue. CBSE 2015
Answer:<P>
<FONT color=“blue”>
</FONT>
</P> or
</P style = “color : blue”>
Question 7. Difference between <BR> and <HR> tags.
Answer: <BR> tag is used to insert a line break which means the text/image following the tag will be
moved to the next line while <HR> tag is used to insert horizontal line that can divide the information
into sections.
Question 8. How is <OL> tag different from <UL> tag? CBSE 2004
Answer: <OL> tag is used to indicate a list item as contained in an ordered or numbered form. <UL> tag
is used to indicate a list item as contained in an unordered or bulleted form.
Question 9. What is the output of the following segment of the HTML code? CBSE 2010
<BODY>
<HR width=‘‘50%”>
<UL>
<LI> MANGO </LI>
<LI> APPLE </LI>
<LI> GRAPES </LI>
</UL> </BODY>
Answer: Output

 MANGO
 APPLE
 GRAPES
Question 10. Write a code to produce the following output.
Answer:
<HTML><BODY>
<DL><DT><B>Computer</B>
<DD>An electronic machine
<DT><B>CPU</B>
<DD> Brain of computer </DL>
</BODY></HTML>
Long Answer Type Questions [5 Marks each]
Question 1. Distinguish between <BASEFONT> tag and <FONT> tag with the help of an example
of each.
Answer: <BASEFONT> tag is used to specify the default setting of the text. It takes the same attributes
as <FONT> tag. The only difference is that the <BASEFONT> tag affects all the text that follows until a
new tag affect that is encountered. <FONT> tag affects the text that comes upto its closing </FONT> tag.
e.g. <HTML>
<BODY>
<BASEFONT size=“2” color=“Red">
Hi Everyone
<FONT size=“4”>
HTML is a Web language </FONT>
It is used for creating Web pages.
</BODY>
</HTML>
Question 2. Identify which one is an attribute or a tag? 1) Body 2) Type 3) Br
4)Link

5) Face
Answer: 1) Body – Tag 2) Type – Attribute 3) Br – Tag 4) Link – Attribute 5) Face –
Attribute
Question 3. Write HTML code to display various bullet types.
Answer:
<LI>Lotus</LI>
<LI>Rose</LI>
</UL>
<UL type = “square”>
<LI>Sun</LI>
<LI>Hoon</LI>
</UL>
</BODY>
</HTML>
Output
Question 4. Distinguish between <P> tag and <BR> tag with the help of an example. CBSE 2005
Answer: Distinguishing between <P> tag and <BR> tag are as follows:
<P> tag <BR> tag
It is a container element. It is an empty element.
It is used to define a
It is used to insert line
paragraph of the text on the
break.
Web page.
It inserts line break with It does not insert any extra
extra space in the beginning. space.
This tag has an attribute
This tag has no attribute.
align.
e.g.
e.g.
<HTML>
<HTML>
<BODY>
<BODY>
This is a 1 ine break <BR>
<P> This ts a paragraph.</P>
into the Web document.
</BODY>
</BODY>
</HTML>
</HTML>
Multiple Choice Questions [1 Mark each]
Q1. HTML is a
(a) package (b) software (c) markup language (d) None of these
Answer: (c) HTML is a markup language which is used to define the layout and attributes of WWW
document.
Q2. HTML tags are enclosed in
(a) curly brackets (b) square brackets (c) double quotes (d) angular brackets
Answer: (d) HTML tags are enclosed within angular brackets (< and >).
Q3. Which of the following tag identifies the document as an HTML document?
(a) <HTML> (b) <HEAD> (c) <BODY> (d) <P>
Answer: (a) tag identifies the document as an HTML document.
Q4. Container elements in HTML require CBSE 2015
(a) starting tag (b) ending tag (c) starting and ending tags (d) None of the above
Answer: (c) In HTML, container elements are required as both starting and ending tags.
Q5. HTML tags are
(a) in uppercase (b) case sensitive (c) in lowercase (d) not case sensitive
Answer: (d) HTML tags are not case sensitive means we can write tags either in uppercase or lowercase.
Q6. Which type of tags used by HTML?
(a) tags only for image (b) user defined tags (c) tags only for linking (d) fixed tags defined
by the language
Answer: (d) HTML provides predefined and fixed tags.
Q7. Which program do you need to write HTML code?
(a) Spreadsheet (b) Access (c) Notepad (d) None of these
Answer: (c) From the given options, Notepad is useful program to write HTML code.
Q8. An example of HTML editor is
(a) Notepad (b) Dreamweaver (c) Microsoft Frontpage (d) All of these
Answer: (d) HTML provides various text editors like Notepad, Dreamweaver etc.
Q9. To create an HTML page, you need
(a) text editor (b) Web browser (c) Both (a) and (b) (d) None of these
Answer: (c) Because text editor is required to write HTML code and Web browser is needed to display
the page.
Fill in the Blanks [1 Mark each]
Q1. HTML is a subset of ……… .Answer: SGML
Q2. An element that only has a starting tag and no ending tag is ………….. element.Answer: empty tag
Q3. The tag that requires a opening as well as closing tag is called ………. .Answer: container tag
Q4. The attribute topmargin sets a margin alongwith the top of your ………… element.Answer: BODY
Q5. ………. attribute of BODY tag helps to set background color. Answer: bgcolor
Q6. The ………… tag is used to define basic font size for the HTML page.
Answer: <BASEFONT>
Q7. The ……….. tag is used to make the Web browser ignore anything that the tag contains.Answer: <!–
…..–>
Q8. ……….. tag is used to bring the text to new line. CBSE 2014 Answer: <BR>
Q9. HR tag is used for ……….. Answer: horizontal line
Q10. …….. and ……… tags break the line flow. Answer: <BR>, <HR>
Q11. ………… attribute of <HR> tag specifies the width of a horizontal line. Answer: width
Q12. ……… tag is used to make the text bold. Answer: <B>
Q13. <LI> tag is an ………… element tag. Answer: empty
Q14. To display the text in italics, ………. tag is used and to display in type writer font, ……… tag is
used.
Answer: <I>, <TT>
Inserting Images and Links in HTML
Very Short Answer Type Questions [1 Mark each]
Question 1. How can text be displayed in place of image for users whose browser do not support
images?
Answer: The alt attribute of <img> tag is used to display the text in place of image for the users whose
browser do not support images.
Question 2. Write a statement in HTML that inserts an image named ‘school.jpg’ found in the
‘images’ folder of the current folder. In case the image cannot be found, it should display ‘Schools
in India’.
Question 3. The following code is written to align the image in center in the browser’s window.
However, the>desired result is not achieved. Mention the reason.
<img src = “image.jpg” align = “center”>
Answer: The reason for not getting the desired result is that center is not a value of align attribute in
<img> tag.
Question 4. Why width and height attributes are used?
Answer: The width and height attributes are used, such that downloading of an image will be faster after
knowing the dimensions of the images in the browser.
Question 5. What do you mean by hypertext?
Answer: Hypertext acts as a link on which you click to navigate to the desired content.
Question 6. In HTML, how linking can be done?
Answer: In HTML, linking can be done by using anchor <a> tag followed by href attribute.
Question 7. Explain linking.
Answer: When one Web page or a text fragment is connected to another Web page, then it is called
linking. It is of two types— internal linking and external linking.
Question 8. What happens when we click on a hyperlink in a Web page?
Answer: When we click on a hyperlink in a Web page, it provides a link that leads from one document to
another.
Question 9. Give the expansion of the following i) alt ii) <a>
Answer. 1) alt is used for alternate text attribute. 2) <a> is used for anchor tag.
Question 10. Write the HTML command to display the following in your Web page. A2 + B2
Answer: The HTML command is – A<sup>2</sup> + B<sup>2</sup>
Question 11. Write the output on the Web page for the following HTML command.
<u>Atomic weight of </u>O<sub>2</sub>
Answer: The output on the Web page will be Atomic weight of O2
Short Answer Type Questions [2 & 3 Marks each]
Question 1. Describe the use of alt attribute with <img> tag.
Answer: The alt attribute is used to define ‘alternate text’ for an image. It tells the Website visitor, what
he/she is missing on the page if the browser cannot load images. The browser will then display the
altertnate text instead of the image. It is good to include alt attribute for each image on a page to improve
the appearance and usefulness of the document.
Question 2. Write the HTML code to display an image on the right side of the page.
Answer:
<html>
<body>
<img src="image.jpg" align="right">
</body>
</html>
Question 3. Name the values that can be assigned to align attribute of <img> tag.
Answer: The values that can be assigned to align attribute of <img> tag are as follows:
i) Top ii) bottom iii) left iv) right v) middle
Question 4. Write the HTML code to display an inline image named pencil.jpg located at C:\ in the
center of your Web page.
Answer:
<html>
<body>
<center>
<img src="C:\pencil.jpg">
</center>
</body>
</html>
Question 5. Define height and width attributes of <img> tag.
Answer: The width and height attributes tell the dimension of an image to the browser. Both (height and
width) attributes require integer values (dimension of image in terms of either pixels or percentage of its
actual size).
<img src=”picture.jpg” height = “50” width = “50”>
Question 6. Identify the errors in the following HTML code and write the correct code with each
correction underlined.
<html>
<title>IMAGES</head>
<body bgcolor="PICI.JPG">
<img href="ABC.JPG">
HERE IS MY IMAGE FILE
</bgcolor>
</html>
Answer:
Error 1 The <title> tag must be within <head> element.
Error 2 bgcolor attribute of body element supports a color like red, green or its color value.
Error 3 <img> tag needs a source attribute src to place an image.
Error 4 body element must be closed not bgcolor attribute.
The correct code is as follows:
<html>
<head>
<title>IMAGES</title>
</head>
<body bocolor = "yellow">
<imq src= "ABC.JPG">
HERE IS MY IMAGE FILE </body>
</html>
Question 7. Explain the need of linking between Web pages.
Answer: Linking between different Web pages is required, as when we create Websites, different html
files (Web pages) are created. These files contain different modules and cannot be open individually. If
we link between them, the Website becomes more productive and informative.
Question 8. How is external linking different from internal linking? CBSE 2004, 05
Answer: External link is a type of linking that goes to another Website. It is a linking of two different
documents. While, internal linking is a type of linking that links pages within a single Website, various
sections of same document or different document.
Question 9. Explain the given command
<a href =”wild.html”>Click Here for wild animals</a> CBSE 2006
Answer: In this command, anchor <a> tag and its href attribute is included. The text (Click Here for wild
animals) will appear underlined and indicates that clicking the text activates the hypertext link. The
address of the referenced document can be specified by an absolute or relative URL.
Thus, “wild.html” is an URL or Web page address and Click Here for wild animals is the hyperlinked
text.
Question 10. Name the attributes of <a> tag which are used for internal linking in a Web page.
CBSE 2014, 13
Answer:The attributes of <a> tag which are used for internal linking in a Web page as follows:

1. href used to specify the URL of the segment the link goes to.
2. name gives the name to the segment.
Question 11. What is the purpose of using the attribute href in <a> tag?
Answer: The href stands for Hypertext Reference. The href attribute is used with <a> tag to specify link
to some other HTML page or Website.
e.g. <a href “”https://www.learncbse.in”>
click here </a> to go to learncbse.
It will display like:
click here to go to learncbse.
Question 12. Write the HTML code to create a link for school .jpg located at C:\. CBSE 2014
Answer:
<html>
<body>
<a href = "C:\school. jpg">Image</a>
</body>
</html>
Question 13. Write an simple HTML code to show an example of internal linking.
Answer:
<html>
<head><title>Internal Linking</title>
</head>
<body>
<h1>It is <a name ="top">top</a> of the page </h1>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br>
<h1><a href ="#top">Top</a></h1>
</body>
</html>
Question 14. What is the purpose of mailto function?
Answer: The mailto function is used to send E-mail messages to multiple recipients. For this, we only
need to type the E-mail address of the recipients in the same link separated by commas.
Question 15. Write an HTML code to show the use of mailto function.
Answer:
<html>
<head>
<title> Use of mailto </title>
</head>
<body>Send your views to
<a href= "mailto:[email protected]"> [email protected]< / a >
</body>
</html>
Question 16. Write the HTML code to send an E-mail to [email protected] from your Web page.
Answer:
<html>
<body>
<a href="mailto:[email protected]">[email protected]</a>
</body>
</html>
Question 17. Distinguish between <sup> and <sub> tags with example.
Answer: Distinguishes between <sup> and <sub> tags are as follows:
<sup> Tag <sub> Tag
The <sup> tag is known The <sub> tag is known as
as superscript tag. subscript tag.
It is used to define It is used to define
superscripted text. subscripted text.
Tags that are used to
Tags that are used to specify
specify superscripted
subscripted written as
written as
<sub> text </sub>
<sup> text </sup>
e.g. HTML command to
e.g. HTML command to
display
display
log 2+log x is
(a+ b) 2 is
log <sub>2</sub>+log
(a+ b) <sup>2</sup>
<sub>x</sub>

Question 18. Write the full forms of: i) <sup> ii) <a> iii) <img> iv) <sub>
Answer: i) <sup>Superscript ii) <a> Anchor
ii) <img> Image iv) sub> Subscript
Multiple Choice Questions [1 Mark each]
Q1. Web browsers display images in the following format
(a) XBM (b) JPEG (c) GIF (d) All of these
Answer: (d) All of these
Q2. Which tag is used to insert an image in Web page?
(a) <a> (b) <table> (c) <img> (d) <p>
Answer: (c) <img> tag is used to insert inline image in a Web page.
Q3. The correct HTML code for inserting an image is CBSE 2012
(a) <img href=”image.gif”> (b) <img> image.gif</gif>
(c) <img src = “image.gif”> (d) <image src = “image.gif” >
Answer: (c) <img src=”image.gif “>
Q4. src attribute used with <img> tag stands for CBSE 2013
(a) screen (b) screen resolution count (c) source (d) structure
Answer: (c) source
Q5. …………. attribute is used to specify the location of an image file.
(a) alt (b) src (c) align (d) name
Answer: (b) src attribute is used to specify the location of an image file.
Q6. The default alignment of images, that are inserted in Web page, is
(a) left (b) right (c) inline with text (d) middle
Answer: (c) An image which is inserted in Web page by default placed inline with text.
Q7. Which is not a valid value in the align attribute of <img> tag? CBSE 2014,2013
(a) top (b) center (c) bottom (d) right
Answer: (b) center is not a valid value in the align attribute of <img> tag. To align in center, <center> tag
can be used.
Q8. The <a> tag is
(a) a container tag (b) an empty tag (c) a closing tag (d) None of these
Answer: (a) <a> is a container tag, which requires starting as well as matching ending tag.
Q14. ………… is the default color of a hyperlink.
(a) Red (b) Blue (c) Green (d) Black
Answer: (b) Blue
Q15. The tag used in HTML to link a Web page with other Web page is CBSE 2013
(a) <a> (b) <h> (c) <u> (d) <l>
Answer: (a) <a> anchor tag is used to create links.
Q16. Which tag tells, where a link starts? CBSE 2014
(a) <1> (b) <start> (c) <a> (d) None of these
Answer: (c) <a> tag specify that a link starts, in which, href create a hyperlink.
Q17. Which command should be use to link a page with HTML page? CBSE 2013
(a) <a link = “page.htm” > </a> (b) <a href = “page.htm”>page</a>
(c) <a connect = “page.htm”></a> (d) <a attach = “page.htm”></a>
Answer: (b) <a href=”page.htm”>page</a>
Q18. With which code you .can make an image works as link? CBSE 2016
(a) <a href = “URL”>Text</a> (b) “<a href=”ABC.html”><img src =”graphic.gif”>Click Here</a>
(c) <a ref=mailto:<img src = graphic.gif>Click Here</a> (d) None of the above
Answer: (b) With <a href=”ABC.html”><img src= “graphic.gif >Click Here</a> image works as link.
Q19. To create a hyperlinked image
(a) the image tag should be within anchor tag (b) the anchor tag should be within image tag
(c) the image tag should be before the anchor tag (d) the image tag should be after the anchor tag
Answer: (a) The image tag should be within anchor tag to create hyperlinked image.
Q20. For internal linking, the section names are provided by attribute of <a> tag.
(a) title (b) href (c) name (d) None of these
Answer: (c) For internal linking, section names are provided by name attribute.
Q21. Is it possible to link within the current page?
(a) No (b) Only in framesets (c) Yes (d) None of these
Answer: (c) Yes, it is possible to link within the current page, which is called internal linking.
Q22. ………. attribute of the <a> tag is used to name a section in a Web page to create an internal
link.
(a) href (b) name (c) align (d) link
Answer: (b) name attribute is used to create an internal link.
Q23. …………….. attribute is used to set the color of a link while it is active.
(a) vlink (b) alink (c) Both(a) and (b) (d) None of these
Answer: (b) alink attribute is used to set the color of link while it is active.
Q24. The attribute which is used to send E-mails through a Website.
(a) tomail (b) mailto (c) Both(a) and (b) (d) None of these
Answer: (b) mailto attribute is used to send E-mails through a Website.
Q25. Choose the correct syntax to create an E-mail link. CBSE 2014
(a) <a href = “[email protected]”> (b) <a href = “mailto:[email protected]”>
(c) email = “[email protected]”> (d) <amail = “[email protected]”>
Answer: (b) <a href = “mailto:[email protected]”>
Q26. To display (X+Y)2, correct HTML code is CBSE 2013
(a) <sub>(X+Y)2</sub> (b) X+Y< sup > 2 </sup >
(c) (X+Y)<sup>2</sup> (d) <sup>(X +Y)2</sup>
Answer: (c) (X+Y) <sup>2</sup> code is correct because superscript have to be placed in between
<sup> and </sup> tags.

Working with Tables in HTML


Multiple Choice Questions [1 Mark each]
Question 1. Which of these tags belong to table? CBSE 2016
(a) <thead>,<body>,<tr> (b) <table>,<head>,<tfoot>
(c) <table>,<tr>,<td> (d) <table>,<tr>,<tt>
Answer: (c),<table>,<tr>, <td> tags are used with table.
Question 2. Which of the following tags gives a caption to the table?
(a) < caption > (b) < summary > (c) < frame > (d) None of these
Answer:(a) <caption> tag is used to give caption to the table.
Question 3. Which of the following is used to specify the beginning of a table’s row?
(a) <table> (b) <tr> (c) <row> (d) <begin>
Answer:(b) <tr> tag indicates the beginning of a table’s row.
Question 4. HTML tag for row is
(a) <colspan> (b) <tr> (c) <rowspan> (d) <td>
Answer: (b) HTML tag for row is <tr>.
Question 5. Which tag is used to add columns in the tables?
(a) <colspan> (b) <td> (c) <tr> (d) None of these
Answer: (b) <td> is used to add columns in the tables.
Question 6. The tag is used to specify the individual table data in a table.
(a) <tr> (b) <td> (c) <th> (d)<table>
Answer:(b)The <td> tag is used to specify the individual table data in a table.
Question 7. In order to add border to a table, border attribute is specified in which tag?
(a) <th> (b) <table> (c) <td> (d) <tr>
Answer:(b) border attribute is specified in <table> tag.
Question 8. The attribute used to set the border color of a table is
(a) border (b) bordercolor (c) color (d) border color
Answer:(b) bordercolor is used to set the border color of a table.
Question 9. The frame attribute contains types of values.
(a) 9 (b) 3 (c) 6 (d) 4
Answer: (a) The frame attribute contains 9 types of values.
Question 10. Which of the following is an attribute of < table > tag?
(a) src (b) cellpadding (c) link (d) bold
Answer:(b) cellpadding is an attribute of <table> tag.
Question 11. Which one of the following is not an option for aligning data in a table?
(a) justify (b) right (c) left (d) center
Answer:(a) justify option is not used for aligning data in a table.
Question 12. Which attribute of the < table > tag is used to set an image in the background of a
table?
(a) bgcolor (b) background (c) frame (d) rules
Answer:(b) background attribute is used to set an image in the background of a table.
Question 13. The attribute used to specify the background cofor of a table is
(a) color (b) bgtable (c) backcolor (d) bgcolor
Answer: (d) bgcolor is used to specify the background color of a table.
Question 14. The two common attributes of the <img> and the <table> tag are
(a) src and height (b) height and width
(c) border and src . (d) they do not have any common attributes.
Answer:(b) height and width are common attributes of the <img> tag and the <table> tag.
Question 15. border, frame, cellspacing, cellpadding, align are the attributes of
(a) <body> tag (b) <img> tag (c) <table> tag (d) None of these
Answer: (c) border, frame, cellspacing, cellpadding, align are the attributes of <table> tag.
Question 16. Which of the following is not an attribute of < table > tag?
(a) border (b) background (c) bgcolor (d) src
Answer:(d) src is not an attribute of <table> tag.
Question 17. In the <td> tag, td stands for
(a) Table Data (b) Table Time and Date (c) Table Date (d) None of these
Answer:(a) td stands for Table Data.
Question 18. What is the correct HTML code to left align the content inside a table cell?
(a) <td valign = “left”> (b) <td align = “left”> (c) <td left align > (d) <td left>
Answer:(b) <td align = “left”>
Question 19. Choose the correct HTML code to right align the content inside a table cell.
(a) <td align = “right” > (b) <td valign = “right” > (c) <td rightalign> (d) <td right = “align”
>
Answer: (a) <td align =”right”>
Question 20. Combining two or more cells in a table on a Web page is called
(a) merging (b) spanning (c) combining (d) None of these
Answer:(b) Combining two or more cells in a table on a Web page is called spanning.
Question 21. Which attribute tells, how many rows a cell should span?
(a) colspan = n (b) rowspan = n (c) Both (a) and (b) (d) None of these
Answer:(b) rowspan = n will tell how many rows a cell should span.
Question 22. rowspan = n can be added to only which tag?
(a) <hr> (b) <table> (c) <td> (d) <tr>
Answer: (r) rowspan = n can be added to only <td> tag.
Question 23. Which attribute of <td> tag is used to merge two or more columns to form a single
column?
(a) colspan (b) cellspacing (c) cellpadding (d) rowspan
Answer: (a) colspan attribute is used to merge two or more columns to form a single column.
Question 24. colspan = n can be added to tag.
(a) <hr> (b) < table > (c) <td> (d) <tr>
Answer:(r) colspan = n can be added to <td> tag.
Question 25. The attribute helps to align data vertical in a single cell.
(a) align (b) valign (c) halig (d) Both (b) and (c)
Answer:(b) valign attribute is used to align data vertically in a single cell.
Question 26. In the <th> tag, th stands for
(a) Table Heading (b) Total Heading (c) Table Header (d) All of the above
Answer: (c) th stands lor Table Header
Very Short Answer Type Questions [1 Mark each]
Question 1. Name the tags which are used with <table> tag.
Answer: <tr>,<td>,<th> and <caption> tags are used with <table> tag.
Question 2. Describe the border attribute of <table> tag.
Answer: The border attribute is used to define- the thickness of the border, which surrounds the table.
Question 3. Why bordercolor attribute is used?
Answer: The bordercolor attribute is used to specify the color of the table’s border
Question 4. Name any two values specified in frame attribute.
Answer: The values that can be specified for frame attribute are void and above.
Question 5. Which attribute lets you control the display of select border sides of a table?
Answer: frame attribute displays the selected border sides of the table.
Question 6. How many values can be specified in rules attribute of <table> tag?
Answer: There are total five values that can be specified for rules attribute.
Question 7. Define cellspacing.
Answer: The cellspacing is used to create space between different cells in a table.
Question 8. Name two table attributes, which are used to set spacing in and between table cells.
Answer: The cellspacing and cellpadding are the attributes, which are used to set spacing in and between
the table celts.
Question 9. What is the use of align attribute in < table > tag?
Answer: The align attribute defines the center, right or left alignment of the <tabie> tag.
Question 10. Name the values that can be used in valign attribute.
Answer: The values that can be used in valign attribute are top, middle and bottom.
Question 11.Why valign attribute is used? CBSE 2005
Answer: The valign attribute is used with <td> tag which helps to align data in a single cell if the cell
span in more than one row.
Question 12. With which tag) align attribute is used?
Answer: The align attribute is used with both <td> tag and <table> tag.
Question 13. Which tag is used for giving heading to the columns?
Answer: The <th> tag is used to display the table heading only once for a table column.
Question 14. Which tags divide HTML tables in multiple section?
Answer: <thead>, <tfoot> and <tbody>
Question 15. What is the difference between <thead> and <tfoot> tags?
Answer: The <thead> tag is used to add a header in a table while <tfoot> tag is used to add a footer in a
table.
Question 16. Can you insert hyperlinks inside table cells?
Answer: Yes, in spite of text we just have to insert the anchor tag between the <td> and </td> tags.
e.g.<td>
<a href = “www.google.com”>link </a></td>.
Short Answer Type Questions
Question 1. Differentiate between cellspacing and cellpadding in HTML table.
Answer:Differences between cellpadding and cellspacing are as follows:

Question 2. 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 are used for specifying its dimensions in a Web page,
width and height are specified in terms of pixels or percentage of the browser window.
Question 3. 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 pixels or in percentage of the browser window, e.g.
<table width = " 150">
<tr><td>Celll</td><td>Cell2</td></tr>
<tr><td>Cell</td><td>Cell4</td></tr>
</tab1e>
Question 4. 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 5. 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.
Question 6. Why rowspan and colspan attributes are used?
Answer:Sometimes, a table cell is bigger than other. Its span is spread to more rows or columns. Such
cells can be created with the help of rowspan and colspan attributes.
Question 7. Which attributes can you use with < table > tag but not with <tr> tag?
Answer:summary, rules, frame,*, border, cellpadding, cellspacing, height, width and bordercojor are the
attributes that you can use with <table> tag but not with <tr> tag.
Question 8. Define the <th> and <tr> tags. Are these two tags similar? If yes, how?
Answer: <th> tag stands for Table Header. It is used to give headings to the various columns in our table.
<tr> tag 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> also defines a data cell, which is taken as heading to the
columns and the data is bold faced.
Question 9. What is header cell? Name the < table > tag, which is used as header cell.
Answer: The table header cell is coded with <th> tag. It 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.
Question 10. What are table sections? How can they be created?
Answer: In HTML tables, there are three different sections: header, body and footer. These sections can
be created using <thead> (header section), <tbody> (body section) and <tfoot> (footer section) tags.
e.g
<table>
<thead>
<tr> <th> Month</th><th>Savings</th></tr> </thead>
<tbody>
<tr><td>January</td><td>$100</td></tr>
<tr><td>February</td><td>$80</td></tr>
</tbody>
<tfoot>
<tr><td>Sum</td><td>$180</td></tr>
</tfoot>
</tab1e>
Question 11. Name the attributes that are used to do the following in HTML:
1) merge two or more rows. 2) change the background color of the cells in a
table.
2) vertically align cell content. 4) merge two or more columns.
Answer 1) rowspan 2) bgcolor 3) valign 4) colspan
Question 12. Name the attributes used for following:
1) setting the cell width. 2) setting cell’s background image.
2) setting cell’s background color. 4)changing the cell span.
Answer: 1) width 2) background 3) bgcolor 4) rowspan and colspan
Long Answer Type Questions [5 Marks each]
Question 1. 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" val i gn = "middle"> <th> ADMNO </th>
<th>SNAME</th>
<th>NAME</th>
<th>DOB</th>
</tr>
<tr align="left" valign="bottom">
<td>1110</td>
<td>MANJIT</td>
<td>RANJIT</td>
<td>4-MAR-1998</td>
</tr>
</table>
</body>
</html>
Question 2. Write an HTML code to create the following table:

Note:First row has Green background


Answer:The HTML code is
<html>
<body>
<table border="2" align="left"> <thead bgcolor="green">
<tr>
<td>Roll Number</td>
<td>Name</td>
<td>Class</td>
</tr></thead>
<tbody>
<tr>
<td> 100 </td>
<td> Amit </td>
<td> 10 A </td>
</tr>
<tr>
<td> 101 </td>
<td> Ankit </td>
<td> 10 B </td>
</tr>
</tr>
<td> 102 </td>
<td>Arnab </td>
<td> 10C </td>
</tr>
</tbody>
<tfoot>
<tr>
<td> Footer 1 </td>
<td> Footer 2 </td>
<td> Footer 3 </td>
</tr>
</tfoot>
</table>
</body>
</html>
Question 3. 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 4.
Observe the following table and write the HTML code to generate it:

Note : 1st row has pink background.


Answer:The HTML code is
<html>
<body>
<table border = "1">
<tr bgcolor = "pink" align = "center">
<th>question< /th >
<th>marks</th></tr>
<tr><td rowspan = "3">l</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
</tr>
<tr>
<td>5</td>
</tr>
</table>
</body>
</html>
Question 5.
Observe the following table and write the HTML code to generate it:

Answer:The HTML code is


<html>
<body>
<table cell padding = "10"
cell spacing="0" border="l">
<tr align = "center">
<th>Periodl</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 6. Write names of two attributes each for the following tags: CBSE 2013

1. <hr>
2. <body>
3. <img>
4. <table>
5. <a>

Question 7. Identify which of the following is a tag or an attribute ? CBSE 2014


i) Link ii) table iii) align iv) href v) br
Answer: i) link — attribute ii) table — tag iii) align — attribute
iv) href— attribute v) br — tag
Question 8. 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="l" width = "400”>
<tr align="right">
<th>MOVTD</th>
<th>MOVNAME</th>
<th>ACTORS</th>
</tr>
<tr align="1eft">
<td>M001</td>
<td>HIT FACTORY</td>
<td>4</td>
</tr></table></body>
</html>
Question 9. 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 Xbody>
<table border="l">
<tr>
<th colspan="4" align=”center">Shopping Mall/th ></tr>
<tr align = "center"
<td>Floor</td>
<td>No. ofToyCbr>Shops</td>
<td>No. of FoodCbr>Shops</td>
<td>No. of SportsCbr>Shops</td>
</tr>
</table>
</body></html >
Question 10. Write the complete <TABLE>…</TABLE> tags to create a table with the following
contents. Ensure that the background of each data cell should have the color as specified in the
corresponding column heading.
Answer:
<table)
<caption>Colors</caption)
<tr>
<th>red</th>
<th>green</th>
<th>blue</tl>
<th>orange</th)
<th>cyan</th>
</tr>
<tr)
<td bgcolor="red" width="100" height="50"></td>
<td bgcolor="green" width="100" height="50"></td>
<td bgcolor="blue" width="100" hei ght="50"></td>
<td bgcolor="orange" width="100" hei ght="50"></td> .
<td bgcolor="cyan" width="100" height="50"></td>
</tr>
</table>
Question 11.
Observe the following table and write the HTML code to generate it:

Answer:The HTML code is:


<html>
<body> <basefont face="cambria">
<table border="l" bordercolor="black" cel 1spacing="0" width="320">
<caption> Acdvities </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>

Fill in the Blanks [1 Mark each]


Question 1. To insert a table on a Web page, we use ………………. tag. Answer: <table>
Question 2.The tag to start a table is Answer:<table>
Question 3.…………… tag is used to insert data into a table. Answer: <td>
Question 4.The <td> tag is a ………………… Answer: container
Question 5. The……………. attribute is used to display a specific portion of a table border.
Answer: frame
Question 6. frame attribute is used with…………attribute. Answer: border
Question 7. There are total………… values for rules attribute in <table> tag. Answer: 5
Question 8. In the rules attribute, the………… value helps to display a table border only between rows.
Answer: rows
Question 9. Cellspacing is used to create space between different…………… in a table. Answer: cells
Question 10.The….. is an attribute of the < table > tag to set the distance between the cell content and its
boundary. Answer: cellpadding
Question 11. To set image as background of an HTML table, you can use………………… attribute.
Answer: background
Question 12. By default, color of a table is………….. Answer: white
Question 13. The height and width attributes of < table > tag are specified in terms of………….. or
percentage.
Answer: pixels
Question 14. The… attribute is used to provide information about a table. Answer: summary
Question 15. <td> tag can only be present inside………. Answer: <tr>
Question 16. The………………. attributes is used to combine the cells vertically. Answer: rowspan
Question 17. The……………… attribute is used to span two or more columns in a table.
Answer: colspan
Question 18. The……………… attribute is used to align the data vertically within cells.
Answer: valign
Question 19. The <tr> tag can only be present inside…………tag.
Answer: <table>
Question 20. The <thead> tag is used to specify the………..part of the table.
Answer: header

You might also like