Unit 2
Unit 2
Note: Also, always specify the width and height of an image. If width and height are
not specified, the page might flicker while the image loads.
Tip: To link an image to another document, simply nest the <img> tag inside
an <a> tag (see example below).
<!DOCTYPE html>
<html>
<body>
<h1>The img element</h1>
<img src="img_girl.jpg" alt="Girl in a jacket“ width="500" height="600">
</body>
</html>
HTML <map> Tag
Definition and Usage
• The <map> tag is used to define an image map. An image map is an image with clickable areas.
• The required name attribute of the <map> element is associated with the <img>'s usemap
attribute and creates a relationship between the image and the map.
• The <map> element contains a number of <area> elements, that defines the clickable areas in the
image map.
Example
<!DOCTYPE html>
<html>
<body>
<h1>The map and area elements</h1>
<p>Click on the computer, the phone, or the cup of coffee to go to a new page and read more about
the topic:</p>
<img src="workplace.jpg" alt="Workplace" usemap="#workmap" width="400" height="379">
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer" href=“1.htm">
<area shape="rect" coords="290,172,333,250" alt="Phone" href=“2.html">
<area shape="circle" coords="337,300,44" alt="Cup of coffee" href=“3.html">
</map>
</body>
</html>
<figcaption>
Definition and Usage
• The <figure> tag specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.
• While the content of the <figure> element is related to the main flow, its position is independent of the main flow,
and if removed it should not affect the flow of the document.
• Tip: The <figcaption> element is used to add a caption for the <figure> element.
Example:
<!DOCTYPE html>
<html>
<body>
<h1>The figure and figcaption element</h1>
<figure>
<img src="pic_trulli.jpg" alt="Trulli" style="width:100%">
<figcaption>Fig.1 - Trulli, Puglia, Italy.</figcaption>
</figure>
</body>
</html>
HTML <svg> Tag
Definition and Usage
• The <svg> tag defines a container for SVG graphics.
• SVG has several methods for drawing paths, boxes, circles, text, and
graphic images.
Example:
<!DOCTYPE html>
<html>
<body>
<h1>The svg element</h1>
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke=“red" stroke-width="4" fill="yellow"
/>
Sorry, your browser does not support inline SVG.
</svg>
</body>
</html>
HTML - <a> Tag
Description:
• The HTML <a> tag is used for creating a hyperlink to either
another document, or somewhere within the current document.
Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML a Tag</title>
</head>
<body>
<p>This is a link to <a href =
"http://www.amrood.com">AMROOD.com</a>
</p>
</body>
</html>
Conti…
• The HTML <a> tag also supports the following
additional attributes −
Charset: character_encoding
Defines the character encoding of the linked
document.
Coords:
• if shape = "rect" then coords = "left, top, right,
bottom"
• if shape = "circ" then coords =
"centerx,centery,radius"
• if shape = "poly" then coords = "x1, y1, x2,
y2,..,xn,yn"
Conti…
• Specifies the coordinates appropriate to the
shape attribute to define a region of an image
for image maps.
Download: filename
This downloads the target when user clicks on
the hyperlink.
Href: URL
Specifies the URL of a page or the name of the
anchor that the link goes to.
Name: section name
Marks an area of the page that a link jumps to.
Conti…
Rel: alternate designates style sheet start next prev
contents index glossary copyright chapter section
subsection appendix help bookmark.
Describes the relationship between the current
document and the destination URI.
Rev: alternate designates style sheet start next prev
contents index glossary copyright chapter section
subsection appendix help bookmark.
Specifies the relationship between the target URL
and the current document.
Shape:rect- rectangle, circ- circle, poly- polygon
Specifies the shape of the image map
Conti…
Target:
_blank
_parent
_self
_top
Where to open the target URL.
• _blank - the target URL will open in a new window.
• _self - the target URL will open in the same frame as it was
clicked.
• _parent - the target URL will open in the parent frameset.
• _top - the target URL will open in the full body of the
window.
Type: mime_type
Specifies the MIME (Multipurpose Internet Mail Extensions)
type of the target URL
HTML - <abbr> Tag
Description
• The HTML <abbr> tag is used for indicating an abbreviation like
etc., pvt.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML abbr Tag</title>
</head>
<body>
<p> <abbr title = "Private">pvt.</abbr> <br />
<abbr title = "International Cricket Council">ICC.</abbr> promotes
the global game. <br />
</p>
</body>
</html>
HTML - <address> Tag
Description
• The HTML <address> tag is used for indicating an
address. The address usually renders in italic.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML address Tag</title>
</head>
<body>
<address> 600 Wisdon Apartments<br /> Filmcity,
Kondiura<br /> New Delhi - 50027 </address>
</body>
</html>
HTML - <area> Tag
Description
• The HTML <area> tag is used for defining an area in an image map.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML area Tag</title>
</head>
<body>
<img src = /images/usemap.gif alt = "usemap" border = "0" usemap = "#tutorials"/>
<map name = "tutorials">
<area shape = "poly" coords = "74,0,113,29,98,72,52,72,38,27" href = "/perl/index.htm"
alt = "Perl Tutorial" target = "_blank" />
<area shape = "rect" coords = "22,83,126,125" alt = "HTML Tutorial" href =
"/html/index.htm" target = "_blank" />
<area shape = "circle" coords = "73,168,32" alt = "PHP Tutorial" href = "/php/index.htm"
target = "_blank" />
</map>
</body>
</html>
Conti…
<!DOCTYPE html>
<html>
<body>
<p>Click on the computer, the phone, or the cup of coffee to go to a new page and read more
about the topic:</p>
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
<area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
<area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>
</body>
</html>
<aside> tag
Description
• The HTML <aside> tag is used to specify a section of a page aside
from the related section. This tag can be used for glossary
definitions, author biography, author profile etc.
Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML aside Tag</title>
</head>
<body>
<aside> <h3>Java History</h3>
<p>Java is a programming language developed by James Gosling in
1994.</p>
</aside>
</body>
</html>
HTML - <audio> Tag
Description
• The HTML <audio> tag is used to embed audio in web pages.
<!DOCTYPE html>
<html>
<head>
<title>HTML audio Tag</title>
</head>
<body>
<p>Click on Play button...</p>
<p>(Song: Kalimba which is provided as a Sample Music in
Windows)</p>
<audio controls> <source src = "/html/Kalimba.mp3" type =
"audio/mpeg">
</audio>
</body>
</html>
<track>
• The <track> tag specifies text tracks for <audio> or <video> elements.
• This element is used to specify subtitles, caption files or other files containing text,
that should be visible when the media is playing.
• Tracks are formatted in WebVTT format (.vtt files).
Example
<html>
<body>
<video width="320" height="240" controls>
<source src="forrest_gump.mp4" type="video/mp4">
<source src="forrest_gump.ogg" type="video/ogg">
<track src="fgsubtitles_en.vtt" kind="subtitles" srclang="en" label="English">
<track src="fgsubtitles_no.vtt" kind="subtitles" srclang="no" label="Norwegian">
</video>
</body>
</html>
HTML - <base> Tag
Description
• The HTML <base> tag is used to specify a base URI, or URL, for
relative links.
• For example, you can set the base URL once at the top of your
page in header section, then all subsequent relative links will use
that URL as a starting point.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML base Tag</title>
<base href = "https://www.tutorialspoint.com" />
</head>
<body> HTML: <img src = "/images/html.gif" />
</body>
</html>
Conti...
Attribute Value Description
href URL Specifies the URL of a page or the name of the anchor that
the link goes to.
_top − the target URL will open in the full body of the window
HTML - <basefont> Tag
Description
• The HTML <basefont> tag is used to specify a base font for the
document to use. This base font is applied to complete document.
This tag is depreciated now.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML basefont Tag</title>
</head>
<body> <basefont face = "cursive,serif" color = "#ff9900" size = "4"/>
<p>The HTML basefont tag is now deprecated. You should use CSS
font to set font properties instead.</p>
</body>
</html>
Conti…
• The HTML <basefont> tag also supports the
following additional attributes −
Attribute Value Description
size 1 to 7 Deprecated −
Specifies the font
size of the text.
HTML - <bdo> Tag
Description
• The HTML <bdo> tag is used to override the default text
direction.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML bdo Tag</title>
</head> <body>
<bdo dir = "rtl">Here's some English embedded in text in
another language requiring a right-to-left
presentation.</bdo>
</body>
</html>
Conti…
• The HTML <bdo> tag also supports the
following additional attributes −
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Button Tag</title>
</head>
<body>
<form> <button name = "button" value = "OK" type = "button">Click
Me</button> </form>
</body>
</html>
• The HTML <button> tag also supports the following additional attributes −
Attribute Value Description
autofocus autofocus Specifies that the button should have input focus when the
page loads.
disabled disabled Specifies the button is disabled.
form form_id Specifies the forms to which button belongs.
formaction URL Specifies the link where the form submits.
formenctype application Specifies how the form data is encoded before sending it to
multipart/form-data server.
text/plain
formmethod get Specifies how to send form data.
post
formnovalidate formnovalidate Specifies that the form data should not be validated.
Example:
<!DOCTYPE html>
<html>
<body>
<h1>The var element</h1>
<p>The area of a triangle is: 1/2 x <var>b</var> x <var>h</var>, where
<var>b</var> is the base, and <var>h</var> is the vertical height.</p>
</body>
</html>
Lists
• List is nothing but the collections of items or
elements. There are two types of lists -
unordered lists and ordered lists.
• The unordered list is useful for simply listing
the items but if we want the items in some
specific sequence then the ordered lists are
used. Let us discuss how to use these types
lists in the HTML document.
Unordered List
<!DOCTYPE html> Following are some core subjects on
<html> computer science
<head> <ul type="circle">
<title> Use of Unordered List </title>
<li>Operating system</li>
<li>Computer Network</li>
</head>
<li>Database management
<body> Systems</li>
<h2>All About Computer ...</h2> <li>Web Programming</li>
Following are some popular operating <li>Software Engineering</li>
systems used in computer </ul>
<ul type="disc"> Following are some popular Web
browsers
<li>DOS</li>
<ul type="square">
<li>Windows 98</li> <li>Intenet Explorer</li>
<li>Windows XP</li> <li>Mozilla Firefox</li>
<li>Windows Professional</li> <li>Netscape Navigator</li>
<li>Windows Vista</li> </ul>
<li>Unix</li> </body>
</ul> </html>
Ordered List
• The ordered list is a list of items which must
follows some specific sequence. We can
number the text using tag. Following table
shows various styles by which the list can be
numbered.
Conti…
<!DOCTYPE html> <h4>The list is starting from
<html> 5</h4>
<head> <ol start="5">
<title> Ordered List Demo <li>Ice cream</li>
</title>
<li>Mango</li>
</head>
<body>
<li>Juice</li>
<h4>This is a typical List</h4> <li>Pop Corn</li>
<ol type="A"> <li> and so on</li>
<li>First</li> </ol>
<li>Second</li> </body>
<li>Third</li> </html>
<li>Forth</li>
<li> and so on</li>
</ol>
Tables
• For systematic arrangement of information we often require tabular structure.
HTML allows us
• to create tables on the web pages.
• Many web designers are using invisible tables on the web pages.
• The biggest advantage of using tables on the web pages is that the information gets
arranged
• systematically.
• The table is a matrix of rows and columns and the area formed due to intersection of
a row and a
• column is called cell.
• 2.8.1 Basic Table Tag
• To create a table on the web page the table beginning tag is <table> and </table> tag
is used for
• ending the table.
• Within <table> … </table> tag we can create rows and columns.
• The rows are created using <tr> </tr> and columns are created using <td> </td>
HTML Document[TabDemo.html]
<!DOCTYPE html>
<html>
<head>
<title> Table Demo </title>
</head>
<body>
<br/><br/>
<center>
<table border="5">
<caption align="bottom">
<b> Table Demo </b>
</caption>
<tr>
<td>This is Left cell-row 1</td>
<td>This is Right cell -row 1</td>
</tr>
<tr>
<td>This is Left cell-row 2</td>
<td>This is Right cell-row 2</td>
</tr>
</table>
</center>
</body>
</html>
Script Explanation
• 1) In above program, the parameter border=“5” is set
in order to set the table border. You can give any value
to set the desired border.
• 2) The caption to the table is given by the parameter
caption, we can set this caption either at the top or at
the bottom by using the parameter align.
• 3) Then using the tag the table row can be set. The tag
is used to create columns from left to right.
• 4) Thus in the above program we are filling up the
table values from top to bottom and from left to right.
Just refer the output provided along with the program
for clear understanding of look and feel of the table.
HTML Forms
FORMS:
• Form is a typical layout on the web page by which a user can interact with
the web page.
• Typical component of forms are text, text area, checkboxes, radio buttons
and push buttons.
• HTML allows us to place these form components on the web page and
send the desired information to the destination server.
• All these form contents appear in the <form> tag. The form has an
attribute action which gets executed when user clicks a button on the
form.
Various attributes of form are –
Attribute Description
Action It specifies the url where the form should be submitted.
Method It specifies the HTTP methods such as GET, POST
Name This attribute denotes the name of the form.
target It specifies the target of the address in the action attribute.
Text
• Text is typically required to place one line text. For example if you
want to enter some name then it is always preferred to have Text
field on the form.
• The text field can be set using
<input type="text" size=”30” name =”username” value=" ">
• The input type is text and the value of this text field is “ ” That
means the blank text field is displayed initially and we can enter
the text of our choice into it. There is size parameter which allows
us to enter some size of the text field.
Some other parameters or attributes can be