Cha. 2 Introduction to HTML and Cha. 3 Advanced HTML
Cha. 2 Introduction to HTML and Cha. 3 Advanced HTML
Exercises
OBJECTIVE TYPE QUESTIONS
A. MULTIPLE CHOICE QUESTIONS (MCQs)
THEORETICAL QUESTIONS
1. Write the HTML code to display a horizontal line of red color.
Ans:
<HTML>
<HEAD>
<TITLE>
RED HORIZONTAL LINE
</TITLE>
<HEAD>
<BODY>
<BR><H1> DISPLAY RED HORIZONTAL LINE</H1> <BR><BR>
<HR COLOR="red">
</BODY>
</HTML>
2. Write the HTML code to create a paragraph whose text color is Red.
Ans:
<HTML>
<HEAD><TITLE>A paragraph whose text color is Red </TITLE><HEAD>
<BODY>
<font color=”red”>
<p style="color: red";> Paragraph text in red color </p>.
</font>
</BODY>
</HTML
7. Name the attribute used with <A> tag to specify the URL of link.
Ans: The href attribute is used to define hyperlink in the <a> element.
10. Identify the errors and write the correct HTML statements:
a. <BODY BGCOLOUR= “Red”>
b. <FONT TYPE = “Arial”>
Ans:
a. <body bgcolor= “Red”>
b. <font face = “Arial”>
11. Write the html code to make background appear blue, text yellow, recently visited link green
and selected link as purple.
Ans: <BODY BGCOLOR = #0000FF TEXT = #FFFF00 LINK = 00ffff VLINK = 00FF00 ALINK = #800080>
13. Write down the correct syntax for creating a link on a webpage.
Ans:
<A HREF = " https://www.google.com/ "> is the correct syntax for creating a link to webpage.
Example
<A HREF = " https://www.google.com/ "> Open Google search engine </A>
Explanation:
<a> tag refers to hyperlink.
It is used to define a link among webpages.
<a> has an attribute named as href attribute.
The webpage which is to be linked is mentioned in href attribute.
By default, an unvisited link is visible underlined and blue.
14. Write the HTML code to set page title as “My First Webpage”.
Ans:
<HTML>
<HEAD>
<TITLE>My First Webpage</TITLE>
</HEAD>
</HTML>
15. Write the HTML code to set image favorite.gif on your webpage.
Ans: <img src="C:\Users\Desktop\favorite.gif">
16. Name the attributes of <A> tag used to create an internal link in a webpage.
Ans: Internal link is linked within the same webpage. In this type of linking, a particular section is
defined by an <a> tag, used as the anchor point name, and is referred to an internal link into the
same page
<HTML>
<HEAD>
<TITLE>Internal Linking</TITLE>
</HEAD>
<BODY>
<A NAME="first"> <B>Fossil Fuels</B></A>
<P>The growing demand for energy was largely met by the fossil fuels – coal and petroleum. Our
technologies were also developed for using these energy sources. But these fuels were formed
over millions of years ago and there are only limited reserves. The fossil fuels are non-renewable
sources of energy.</P><BR><BR><BR><BR>
<H2><B>Hydro Power Plants</B></H2>
<P>Hydro power plants convert the potential energy of falling water into electricity </P>
<A HREF="#first"> go to Fossil Fuels</A>
</BODY>
</HTML>
17. Write the HTML code to display text in a particular font type. For example
Font size=5
Font face=Arial
Font color=green
Ans: <font face = "Arial" color=green size=5>
18. Write the html code to display usage of comment.
Ans:
<BODY BGCOLOR="pink">
<H2>Uses of fossil fuel</H2>
<UL>
<LI TYPE="square">In cooking: LPG (Petroleum product), Coal </LI>
<LI TYPE="disc">In vehicles: Petrol, diesels </LI>
<LI TYPE="circle">To produce electricity in Thermal power plant </LI>
</UL>
</FONT>
</BODY>
</HTML>
20. What is the extension of html code file?
Ans: The extension of html code file is .html.
21. Write down the different types of alignment attributes used in paragraphs.
Ans:
Align attribute is used to change the alignment of the paragraph.
<P ALIGN= “left”> used for left alignment of paragraph
<P ALIGN= “right”> used for right alignment of paragraph
<P ALIGN= “justify”> to justify a paragraph
22. Explain the structure of HTML file.
Ans: The basic structure of html file is:
<html>
<head>
<title>
</title>
</head>
<body>
</body>
</html>
23. A website on the topic ‘Green House Effect’ is to be set, which tags are used to give title and
headings of webpage.
Ans:
A <title> tag is an HTML element that specifies the title of a webpage. Heading is a text that is
separated from the other contents on a webpage. There are six heading levels in HTML, i.e., <H1>
to <H6>. As we increase through the heading levels, i.e., from H1 to H6, the size of the heading will
be decreased.
<HTML>
<HEAD>
<TITLE>Green House Effect</TITLE>
</HEAD>
<BODY BGCOLOR="yellow">
<H1>Heading 1</H1>
<H2>Heading 2</H2>
<H3>Heading 3</H3>
<H4>Heading 4</H4>
</BODY>
</HTML>
24. Name the two attributes of the body tag used to specify backgrounds.
Ans: Two attributes of body tag are:
• bgcolor - specifies the background color of a document.
• background- sets an image as background of the webpage.
<BODY BGCOLOR ="yellow"> or <BODY background ="image.jpg">
COMPLETE CODE
<HTML>
<HEAD> <TITLE> Green House Effect< /TITLE> </HEAD>
<p>
Large amount of fossil fuels is burnt every day in power station to heat up water to produce stem
which further runs the turbine to generate electricity. </p>
<br><br>
<p>
The transmission of electricity is more efficient than transporting coal or petroleum over the same
distance. Therefore, many thermal power plant is used since fuel is burnt to produce heat energy
which is converted into electrical energy. </p>
</BODY>
</HTML>
a. Write the HTML code to display the first heading of the webpage.
Ans: <Font face="Arial" color:#0033cc > <H1 > <b> WindEnergy </b> </H1> </Font>
b. Write the HTML tag to display line in blue color.
Ans: <hr width=95% color="blue" size="2">
c. Write down the HTML code to display an ordered list as shown in page.
Ans:
<OL>
<LI> No Pollution </LI>
<LI> Renewable </LI>
<LI> No recurring cost </LI>
</OL>
d. Write the HTML code to display an unordered list as shown in page.
Ans:
<uL type ="disc">
<LI> high set up cost </LI>
<LI> Wind farms can be established at those places where windspeed is greater than 15 km/hr </LI>
<LI> Requires large area around 1 MW-2 hectare land </LI>
</UL>
e. Write the HTML code to change round bullet of unordered list to square bullet.
Ans: <uL type ="square">
f. Is there a nested list in given example?
Ans: Yes
3. Observe the given webpage and write HTML code to generate it.
Complete Code
<HTML>
<Head>
<Title>Energy from the Sea
</Title>
</Head>
<font color=”#ff0000”>
<H2 > <u> Tidal Energy </u> </H2>
</font>
<p> Due to the gravitational pull of mainly the moon on the spinning earth, the level
of water in the sea rises and falls. This phenomenon is called high and low tides and the
difference in sea levels gives us tidal energy. Tidal energy is harnessed by constructing a
dam across opening to the sea. </p>
<font color=”#ff0000”>
<H2 > <u> Wave Energy </u> </H2>
</font>
<p> The kinetic energy possessed by huge waves near the seashore can be trapped in a
similar manner to generate electricity. The waves are generated by strong winds blowing
across thesea. </p>
</Body>
</HTML>
CHAPTER 3: ADVANCED HTML
Exercises
OBJECTIVE TYPE QUESTIONS
A. MULTIPLE CHOICE QUESTIONS (MCQs)
1. Which tag is used to insert an image in a webpage?
a) <A>
b) <IMG>
c) <UL>
d) <DL>
Ans: b) <IMG>
2. To display “bullets” against list items we use:
a) <OL>
b) <UL>
c) Both of them
d) None of them
Ans: b) <UL>
3. Which of these tags belongs to <table> tag?
a) <thead><body><tr>
b) <table><head><tfoot>
c) <table><tr><td>
d) <table><tr><tt>
Ans: c) <table><tr><td>
4. Which one of the following is not an option for aligning data in a table?
a) Justify
b) Right
c) Left
d) Center
Ans: a) Justify
5. With which code you can make an image work as link?
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
Ans: b) <A href= ABC.html> <img src=graphic.gif> Click Here </A>
6. Which of these tags is/are used with <Table> tag?
a) <TR>
b) <TD>
c) <TH>
d) All of the above
THEORETICAL QUESTIONS
1. Write the HTML code to display a table with border of 5px.
Ans:
<html>
<body>
<table border = '5'>
<tr> <td> l </td> </tr>
<tr> <td>2 </td> </tr>
</table>
</body>
</html>
2. Write the HTML code to display an image on the right side of page.
Ans:
<html>
<body>
<img src=”image.jpg” align=”right”>
</body>
</html>
3. Name the attributes of <img> tag which are used for specifying its dimensions in a webpage.
Ans: Width and height
4. Write the full forms of the following:
Ans:
i. <TD> = table definition
ii. HTML = hyper text markup language
iii. ALT = alternate text
iv. <TFOOT> = table foot
6. Write the HTML code to insert an image on webpage named mypic.jpg located at c:\.
Ans:
<html>
<body>
<img src=”c:/mypic.jpg”>
</body>
</html>
Ans:
<table>
<tr>
<th colspan=”4”> My Hobbies </th>
</tr>
<tr>
<td> Dancing </td>
<td> Reading </td>
<td> Swimming</td>
<td> Music</td>
</tr>
<tr>
<td colspan=”4”> Everyone has talent. </td>
</tr>
</table>
9. Write the HTML code to display the given table.
Ans:
<table>
<tr>
<th> A </th>
<th> B </th>
<th> C </th>
</tr>
<tr>
<td rowspan=”2”> D </td>
<td> E </td>
<td rowspan=”2”> F </td>
</tr>
<tr>
<td> G </td>
</tr>
<tr>
<td colspan=”3”> I< /td>
</tr>
</table>
10. Write an HTML code to insert an image to a cell of table.
Ans:
<td>
<img src=”image.jpg”>
</td>
11. Differentiate between cellspacing and cellpadding.
Ans: Cellpadding basically defines the space present between a table cell's border and the content
present in it. Cellspacing basically defines the space present between individual adjacent cells.
12. Write the HTML code to create an ‘image1.jpg’ as a hyperlink to file ‘Description.html’.
Ans: <a href=”description.html”> <img src=”image1.jpg”> </a>
13. Write down the different attributes of <IMG> tag.
Ans: Src and alt
14. How many alignments are available for aligning images in a webpage? Name them.
Ans: In HTML, five types of alignment are available to align an image, which are:
i. Top
ii. Middle
iii. Bottom
iv. Left
v. Right
15. Define <THEAD>, <TBODY> and <TFOOT> tags of a table.
Ans:
<thead> = The <thead> tag is used to group header content in an HTML table.
<tbody> = The <tbody> tag is used to group the body content in an HTML table
<tfoot> = The <tfoot> (short for table foot) element defines a table's footer. It is typically used to
group a set of table rows summarizing the columns of the table
<tr>
<td bgcolor=”yellow”>data1</td>
<td bgcolor=”yellow”>data2</td>
<td bgcolor=”yellow”>data3</td>
<td bgcolor=”yellow”>data4</td>
<td bgcolor=”yellow”>data5</td>
</tr>
<tr>
<td bgcolor=”yellow”>data6</td>
<td bgcolor=”yellow”>data7</td>
<td bgcolor=”yellow”>data8</td>
<td bgcolor=”yellow”>data9</td>
<td bgcolor=”yellow”>data10</td>
</tr>
</table>
17. Observe the following table and write the HTML code to generate it.
Ans:
<table>
<tr>
<th colspan=”2”> SUBJECT </th>
<th> STUDENT A </th>
<th> STUDENT B </th>
</tr>
<tr>
<td colspan=”2”> BIOLOGY </td>
<td> PRACTICAL </td>
<td> A+ </td>
<td> A </td>
</tr>
<tr>
<td> THEORY </td>
<td> A+ </td>
<td> A </td>
</tr>
<tr>
<td colspan=”2”> CHEMISTRY< /td>
<td> PRACTICAL </td>
<td> A+ </td>
<td> A </td>
</tr>
<tr>
<td> THEORY </td>
<td> B+ </td>
<td> B </td>
</tr>
<tr>
<td colspan=”2”> PHYSICS </td>
<td> PRACTICAL </td>
<td> C+ </td>
<td> B </td>
</tr>
<tr>
<td> THEORY </td>
<td> A+ </td>
<td> A </td>
</tr>
</table>
18. Write the HTML code to display an inline image named student.jpg located at c:\ in the
center of your webpage.
Ans:
<html>
<body>
<center>
<img src=”c:\student.jpg”>
</center>
</body>
</html>
21. Name the attributes of <A>tag which are used for internal linking in a webpage.
Ans: <name> and <href> are attributes which are used for internal linking in a webpage.
23. Name the two common attributes of <IMG> and <TABLE> tag.
Ans: Height and width.
There is hyperlink ‘His Awards and Achievements’ of file ‘description.html’ saved in drive d:\.
Ans: <a href=”d:\description.html> His Awards and Achievements </a>
<tr>
<th align=center> Fast Facts </th>
</tr>
<tr>
<td> Years of construction: 1631 </td>
</tr>
<tr>
<tr>
<td> Time taken: 22 years </td>
</tr>
<tr>
<td> Built by: Shah Jahan </td>
</tr>
<tr>
<td> Dedicated to Mumtaz Mahal, wife of Shah Jahan </td>
</tr>
<tr>
<td> Cost of construction: 32 crore rupees </td>
</tr>
<tr>
<td> Number of workers: 20,000 </td>
</tr>
3. Observe the following table and write HTML code to generate it.
Code: <HTML>
<head> <title> table </title> </head>
<BODY>
<tr>
<td rowspan=3 > A </td>
<td colspan=3 > B </td>
</tr>
<tr>
<td > C </td>
<td > D </td>
<td > E </td>
</tr>
<tr>
<td colspan=3> F </td>
</tr>
</body>
</HTML>