HTML Skill
HTML Skill
HTML Skill
Unit - I
Introduction :Web Basics: What is Internet–Web browsers–What is
Webpage – HTML Basics: Understanding tags.
Unit - II
Tags for Document structure (HTML, Head, Body Tag). Block level text
elements: Headings ,paragraph(<p> tag), Font style elements: (bold, italic, font,
small, strong, strike, big tags)
Unit - III
Lists: Types of lists: Ordered, Unordered– Nesting Lists– Other tags :
Marquee, HR, - Using Images –Creating Hyperlinks.
Unit - IV
Tables: Creating basic Table, Table elements ,Caption–Table and cell alignment–
Row span ,Col span–Cellpadding.
Unit - V
Frames: Frameset–Targeted Links–Noframe– Forms: Input, Textarea, Select,
Option.
1
Unit - I
Internet
Internet is a global network that connects billions of computers across the
world with each other and to the World Wide Web. It uses standard internet
protocol suite (TCP/IP) to connect billions of computer users worldwide. Every
computer in internet is identified by a unique IP address.
o Access to online degree programs, courses, and workshops for education and
self-improvement.
3
o Searching for jobs: To advertise available positions, submit job applications,
and hire candidates identified on social networking sites like LinkedIn, both
employers and applicants use the Internet.
o Apart from communication and source of information, internet also serves a
medium for entertainment. Following are the various modes for
entertainment over internet.
o Online Television
o Online Games
o Songs
o Videos
o Social Networking Apps
o Integrated Services Digital Network: With the help of using telephone lines,
ISDN enables users to send audio or video data.
4
Browser
What is Browser?
A browser is a software program that is used to explore, retrieve, and display
the information available on the World Wide Web. This information may be in the
form of pictures, web pages, videos, and other files that all are connected via
hyperlinks and categorized with the help of URLs (Uniform Resource Identifiers).
A browser is a client program as it runs on a user computer or mobile device
and contacts the webserver for the information requested by the user. The web
server sends the data back to the browser that displays the results on internet
supported devices.
The browser sends requests to web servers all over the internet by
using HTTP (Hypertext Transfer Protocol).
o The World Wide Web was the first web browser. It was created by W3C
Director Tim Berners-Lee in 1990. Later, it was renamed Nexus to avoid
confusion caused by the actual World Wide Web.
o The Lynx browser was a text-based browser, which was invented in 1992. It
was not able to display the graphical content.
5
o Although, the first graphical user interface browser was NCSA Mosaic. It
was the first most popular browser in the world, which was introduced
in 1993.
o In 1995, Microsoft introduced the Internet Explorer It was the first web
browser developed by Microsoft.
6
1. User Interface: The user interface is an area where the user can use several
options like address bar, back and forward button, menu, bookmarking, and
many other options to interact with the browser.
2. Browser Engine: It connects the UI (User Interface) and the rendering engine
as a bridge. It queries and manipulates the rendering engine based on inputs
from several user interfaces.
7. Data Storage: The data storage is a persistence layer that is used by the
browser to store all sorts of information locally, like cookies. A browser also
supports different storage mechanisms such as IndexedDB, WebSQL,
localStorage, and File System
7
• Google Chrome:
• Mozilla Firefox
• Internet Explorer
What is a Webpage
A web page is a single hypertext document available on World Wide Web (WWW). It
is composed of HTML elements and displayed on the user's browser such
as Mozilla, Firefox, Chrome, etc. It is also referred to as "Page."
A webpage may contain text, links for other pages, graphics, videos, etc.
Moreover, it is mainly used to provide information to the user in text, images, etc.
Characteristics of a Web Page
Following are some characteristics of a Web page:
o A simple webpage can be created very quickly.
o It takes very little time to create a webpage compared to a Website.
o A web page and a website should be compatible with any device, such as
Mobile, Desktop, Laptop, etc.
o The search engine provides a web page through a link, and when a user clicks
on that link, it is redirected to the webpage of a website.
o A webpage can have any type of information including videos, and audios.
o It can be made up of only HTML(Hypertext Markup Language), or CSS, or
JavaScript for dynamic and attractive behavior.
How does a Web Page Work?
Simple web page is created using HTML, which is a markup language.
However, we can also use CSS and JavaScript to add more functionalities and make
it more attractive.
The webpage is contained within the webserver. To load this webpage, a
client sends the request to the server, once it is responded to by the server, the
browser interprets the markup tags and displays them on the user's screen in the
correct format.
8
The browser sends the request for a page or a file via an HTTP request. The
HTTP is the Hypertext Transfer Protocol, a network protocol that allows
transferring hypermedia documents over the internet between a browser and
server.
Once the request reaches the server, the HTTP server accepts the request,
finds the requested page, and sends it back to the browser through the HTTP
response. If a server is unable to find the requested page, it returns a 404 response.
Elements of a Webpage
The main element of the webpage is a text file composed of HTML. Apart from this,
a webpage can also have the following elements:
o CSS: The CSS code is used to make the page more interactive and control its
look and feel.
o Scripts: The JavaScript code is included in a webpage to add interactivity to
the page and add more functionalities to it.
o Media: It is used to include media components such as audio, video, and
images.
Types of a Web page
There are mainly two types of a Web page based on functionality:
o Static Webpage
o Dynamic Webpage
9
Static Webpage
Static webpages are those webpages that cannot be modified or altered by
the client. These are also known as stationary or flat web pages. They are displayed
on the client's browser in the same format and manner as they are saved in the
webserver.
A static webpage is generally made up of HTML and CSS only.
Dynamic Webpage
Dynamic webpages are dynamic, which means it shows different
information at different point of time.
10
HTML Basics
Introduction
• HTML stands for Hyper Text Markup Language
• HTML was invented by Tim Berners-Lee in 1991.
• HTML is used for creating web pages and web applications.
• It is used to describe the structure of Web pages using markup tags.
Basic Structure of HTML
Each HTML page consists of a set of tags or elements which are known as
the building blocks of web pages. They create a hierarchy that structures the
content into sections, paragraphs, headings, and other content blocks.
11
The DOCTYPE
A DOCTYPE declaration must be specified on the first line of each web
document: The DOCTYPE tells the web browser which version of HTML the page
is written in.
The <head> element contains information about the document, such as its title and
metadata.
<head>
</head>
The <body> element
The <body> element describes the content and structure of the webpage. It may
include things such as text, images, and links.
<body>
<h1> Content Heading </h1>
<p> Content </p>
</body>
Example
<!DOCTYPE html>
<html lang="en">
<head>
12
<meta charset="UTF-8">
<title>Example</title>
</head>
<body>
<h1>SVMC </h1>
</body>
</html>
HTML Elements
An HTML file is made of elements. These elements are responsible for creating web
pages and define content in that webpage. An element in HTML usually consist of
a start tag <tag name>, close tag </tag name> and content inserted between them.
Syntax
<tagname > Contents... </tagname>
• Opening tag: It is used to tell the browser where the content material
starts.
• Closing tag: It is used to tell the browser where the content material
ends.
• Content: It is the actual content material inside the opening and closing
tags.
Example
<h1> Welcome to SVMC </h1>
o Block-level element
o Inline element
13
Block-level element:
o These are the elements, which structure main part of web page, by dividing
a page into coherent blocks.
o A block-level element always start with new line and takes the full width of
web page, from left to right.
o These elements can contain block-level as well as inline elements.
Following are the block-level elements in HTML.
<address>, <article>, <aside>, <blockquote>, <canvas>, <dd>, <div>, <dl>, <dt>,
<fieldset>, <figcaption>, <figure>, <footer>, <form>, <h1>-<h6>, <header>, <hr>,
<li>, <main>, <nav>, <noscript>, <ol>, <output>, <p>, <pre>, <section>, <table>,
<tfoot>, <ul> and <video>.
Example
<html>
<head>
</head>
<body>
<div style="background-color: lightblue">This is first div</div>
<div style="background-color: lightgreen">This is second div</div>
<p style="background-color: pink">This is a block level element</p>
</body>
</html>
Inline elements:
o Inline elements are those elements, which differentiate the part of a given
text and provide it a particular function.
o These elements does not start with new line and take width as per
requirement.
o The Inline elements are mostly used with other elements.
14
<a>, <abbr>, <acronym>, <b>, <bdo>, <big>, <br>, <button>, <cite>, <code>,
<dfn>, <em>, <i>, <img>, <input>, <kbd>, <label>, <map>, <object>, <q>,
<samp>, <script>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <textarea>,
<time>, <tt>, <var>.
Understanding Tags
What is HTML Tag?
HTML tags are like keywords which defines that how web browser will
format and display the content.
HTML tags contain three main parts: opening tag, content and closing tag.
But some HTML tags are unclosed tags.
When a web browser reads an HTML document, browser reads it from top
to bottom and left to right. HTML tags are used to create HTML documents and
render their properties. Each HTML tags have different properties.
Syntax
<tag> content </tag>
Example
<h2> Heading Tag </h2>
<b> Bold Tag </b>
<i> Italic Tag </i>
Unclosed HTML Tags
Some HTML tags are not closed, for example br and hr.
<br> Tag: br stands for break line, it breaks the line of the code.
<hr> Tag: hr stands for Horizontal Rule. This tag is used to put a line across the
webpage.
15
DOCTYPE, title, link, meta and style
HTML Text Tags
<p>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <strong>, <em>, <abbr>, <acronym>,
<address>, <bdo>, <blockquote>, <cite>, <q>, <code>, <ins>, <del>, <dfn>,
<kbd>, <pre>, <samp>, <var> and <br>
HTML Link Tags
<a> and <base>
HTML Image and Object Tags
<img>, <area>, <map>, <param> and <object>
HTML List Tags
<ul>, <ol>, <li>, <dl>, <dt> and <dd>
HTML Table Tags
table, tr, td, th, tbody, thead, tfoot, col, colgroup and caption
HTML Form Tags
form, input, textarea, select, option, optgroup, button, label, fieldset and legend
HTML Scripting Tags
script and noscript
Example
<!DOCTYPE html>
<html>
<head>
<title>My web page</title>
</head>
<body>
<h1>Hello, world!</h1>
<p>This is my first web page.</p>
<p>It contains a
<strong>main heading</strong> and <em> paragraph </em>.
</p>
</body>
</html>
16
Unit - II
TAGS FOR DOCUMENTS STRUCTURE
Html used predefined tags and attributes to tell the browser how to display
content, means in which format, style, font size, and images to display.
Html is a case insensitive language. Case insensitive means there is no
difference in upper case and lower case ( capital and small letters) both treated as
the same, for r example ‘D’ and ‘d’ both are the same here.
17
<!DOCTYPE html>: This tag is used to tells the HTML version. This currently
tells that the version is HTML 5.0
<html> </html> : <html> is a root element of html. In <html > tag we use “lang”
attributes to define languages of html page such as <html lang=”en”> here en
represents English language.
<head>: Head tag contains metadata, title, page CSS etc. Data stored in the
<head> tag is not displayed to the user, it is just written for reference purposes
and as a watermark of the owner.
<title> = to store website name or content to be displayed.
<link> = To add/ link css( cascading style sheet) file.
<meta> = To store data about website, organisation , creator/ owner
<script> = to add javascript file.
<body>: A body tag is used to enclose all the data which a web page has from
texts to links. All the content that you see rendered in the browser is contained
within this element.
Following tags and elements used in the body.
1 . <h1> ,<h2> ,<h3> to <h6>
2. <p>
3. <div> and <span>
4. <b>, <i> and<u>
18
5. <li>,<ul>and<ol>.
6. <img> , <audio> , <video> and<iframe>
7. <table> <th> , <thead>and<tr>.
8. <form>
9. <label> and <input> others……….
Block-level element:
o These are the elements, which structure main part of web page, by dividing
a page into coherent blocks.
o A block-level element always start with new line and takes the full width of
web page, from left to right.
o These elements can contain block-level as well as inline elements.
Following are the block-level elements in HTML.
<address>, <article>, <aside>, <blockquote>, <canvas>, <dd>, <div>, <dl>, <dt>,
<fieldset>, <figcaption>, <figure>, <footer>, <form>, <h1>-<h6>, <header>, <hr>,
<li>, <main>, <nav>, <noscript>, <ol>, <output>, <p>, <pre>, <section>, <table>,
<tfoot>, <ul> and <video>.
Heading Tag
HTML headings are used to create headings and subheadings within a
webpage. There are six levels of headings defined by HTML. These 6 heading
elements are h1, h2, h3, h4, h5, and h6; with h1 being the highest level and h6
being the least.
Six levels of headings in HTML:
19
• h3 - the third level of headings
• h4 - the fourth level of headings
• h5 - the second smallest level of headings
• h6 - being the most smallest heading size
Syntax:
<h1>Heading1</h1>
<h2>Heading2</h2>
.
.
.
<h6>Heading6</h6>
Importance of Heading:
• Search Engines use headings for indexing the structure and organizing the
content of the webpage.
• Headings are used for highlighting important topics.
• They provide valuable information and tell us about the structure of the
document.
20
Example
<html>
<body>
<h1>Welcome to SVMC</h1>
<h2>A computer science portal for SVMC</h2>
<h5>CS</h5>
<h6>BCA</h6>
</body>
</html>
21
Properties of the paragraph tag:
• The<p>tag automatically adds space before and after any paragraph, which is
basically margins added by the browser.
• If a user adds multiple spaces, the browser reduces them to a single space.
• If a user adds multiple lines, the browser reduces them to a single line.
<html>
<body>
<p>
This paragraph has multiple lines. But HTML reduces them to a single line.
</p>
<p>
This paragraph has multiple spaces.But HTML reduces them all to a single
space.
</p>
</body>
</html>
<hr> tag:
The HTML <hr> tag is used to create a horizontal rule or line, visually separating
content on a webpage.
Syntax:
<hr>
Align attribute:
The <p> tag specifically supports the alignment attribute and allows us to align
our paragraphs in left, right, or center alignment.
Syntax:
<p align="value">
Example
<html>
<body>
<p align="center">
Welcome SVMC
</p>
<p align="left">
A Computer Science portal for SVMC
</p>
</body></html>
23
div tag
The <div> tag is known as the Division tag. The div tag is used in HTML
to make divisions of content in the web page like (text, images, header, footer,
navigation bar, etc).
Div tag has both open (<div>) and closing (</div>) tags and it is mandatory
to close the tag.
The Div is the most usable tag in web development because it helps us to
separate data in the web page and we can create a particular section for particular
data or function in the web pages.
24
Font-style elements
Font-style elements are similar to phrase elements in that they are used to
modify pieces of text.
Bold Tag
HTML bold tag is represented by <b> tag.
HTML <b> tag is used to display the written text in bold format. It is strictly a
presentational element.
Example
<p> Hello guys, <b>Good Morning</b></p>
Output
Hello guys Good Morning
Italic Tag
The italic element specifies that text should be rendered in an italic face.
Example
<p> Hello guys, <i>Good Morning</i></p>
Output
Hello guys Good Morning
Small Tag
HTML <small> tag makes text font by one size smaller than the documents
base font size (Such as large to medium, medium to small, etc.)
Syntax
<small>Write your content here...... <small>
Example
<body>
25
<h2>Example of small tag</h2>
<p style="color: green;">This is normal font size.....
<small style="color: blue;">It is smaller than previous...
<small style="color: red;">It is smallest.</small>
</small>
</p>
</body>
Output
Example of small tag
This is normal font size..... It is smaller than previous... It is smallest.
Strong Tag
The HTML <strong> Tag is the parsed tag and is used to show the
importance of the text. The content inside it is generally in bold format.
Syntax
<strong> Contents... </strong>
Example
<html>
<body>
<h1> Strong </h1>
<h2> <strong> Tag </h2>
<strong> Welcome to SVM </strong>
</body>
</html>
Big Tag
HTML <big> tag was used to increase the text font size one level bigger than
the document's base font size or surrounding text size, such as small to medium,
medium to large, etc.
26
Syntax
<big>Content... </big>
Example
<html>
<body>
<h1>Big </h1>
<p>This is paragraph text</p>
<big>This is big Tag text</big>
</body>
</html>
Output
This is paragraph text
Strike Tag
HTML <strike> tag was used to strike a line through the text, contained within it.
Syntax
<strike> content here....</strike>
Example
<body>
<h2>Example of strike tag</h2>
<p><strike>This is not a valid paragraph</strike></p>
<p>This is a valid paragraph</p>
</body>
27
Unit – III
HTML Lists
HTML Lists are used to specify lists of information. All lists may contain one
or more list elements. There are three different types of HTML lists:
o Capital Alphabet (A B C)
o Small Alphabet (a b c)
28
Type Description
Type "1" This is the default type. In this type, the list items are numbered with
numbers.
Type "I" In this type, the list items are numbered with upper case roman numbers.
Type "i" In this type, the list items are numbered with lower case roman numbers.
Type "A" In this type, the list items are numbered with upper case letters.
Type "a" In this type, the list items are numbered with lower case letters.
Example 1:
<ol type="i">
<li>HTML</li>
<li>Java</li>
<li>JavaScript</li>
<li>SQL</li>
</ol>
Output
i. HTML
ii. Java
iii. JavaScript
iv. SQL
Example: 2
<html>
<head>
<title>Order List</title>
</head>
29
<body>
<b>
<ol>
<li> Computer</li>
<li> Computer</li>
<li> Computer</li>
` </ol>
<ol type="a">
<li> Computer</li>
<li> Computer</li>
<li> Computer</li>
</ol>
<ol type="A">
<li> Computer</li>
<li> Computer</li>
<li> Computer</li>
</ol>
<ol type="i">
<li> Computer</li>
<li> Computer</li>
<li> Computer</li>
</ol>
<ol type="I">
<li> Computer</li>
<li> Computer</li>
<li> Computer</li>
</ol>
30
</b>
</body>
</html>
In HTML Unordered list, all the list items are marked with bullets. It is also
known as bulleted list also. The Unordered list starts with <ul> tag and list items
start with the <li> tag.
The HTML ul tag is used for the unordered list. There can be 4 types of bulleted
list:
o disc
o circle
o square
o none
31
Type Description
Type "disc" This is the default style. In this style, the list items are marked with
bullets.
Type "circle" In this style, the list items are marked with circles.
Type In this style, the list items are marked with squares.
"square"
Type "none" In this style, the list items are not marked .
Example1:
ul type="circle"
<ul type="circle">
<li>HTML</li>
<li>Java</li>
<li>JavaScript</li>
<li>SQL</li>
</ul>
Output
o HTML
o Java
o JavaScript
o SQL
Example 2:
<html>
32
<head>
<title>Order List</title>
</head>
<body>
<b>
<ul>
<li> Computer</li>
<li> Computer</li>
<li> Computer</li>
</ul>
<ul type="circle">
<li> Computer</li>
<li> Computer</li>
<li> Computer</li>
</ul>
<ul type="square">
<li> Computer</li>
<li> Computer</li>
<li> Computer</li>
</ul>
<ul type="desc">
<li> Computer</li>
<li> Computer</li>
<li> Computer</li>
</ul>
33
</b>
</body>
</html>
<html>
<head>
<title>LIST</title>
34
</head>
<body>
<dl>
<dt>HTML</dt>
<dd>
<dl>
<dt>CSS</dt>
</dl>
</dd>
<dt>CSS</dt>
<dd>
Cascading Stylesheet
<ul type="square">
<li>HTML</li>
<li>CSS</li>
<li>JS</li>
<li>JQUERY</li>
<li>PHP</li>
</ul>
</dd>
</dl>
</body></html>
35
Nested list?
A nested list is simply a list inside another list. A nested list can be ordered
or unordered.
Nested unordered list
To create an unordered list in HTML, use the ul (unordered list) tag with
the li (list item) tag in a hierarchical structure.
Example
<ul>
<li>
<ul>
<li>Spinach</li>
<li>Kale</li>
</ul>
</li>
<li>
<ul>
36
<li>Carrots</li>
<li>Potatoes</li>
</ul>
</li>
</ul>
Output
• Leafy Greens
o Spinach
o Kale
• Root Vegetables
o Carrots
o Potatoes
Nested ordered list
To create an ordered list in HTML, use the ol (ordered list) tag with the li (list
item) tag in a hierarchical structure.
<ol>
<li>
<ol>
<li>Variables and Data Types</li>
<li>Control Structures</li>
<li>Functions</li>
</ol>
</li>
<li>
<ol>
<li>Arrays and Lists</li>
<li>Stacks and Queues</li>
<li>Trees and Graphs</li>
37
</ol>
</li>
<li>
</ol>
Marquee HTML
The Marquee HTML tag is a non-standard HTML element which is used to
scroll a image or text horizontally or vertically.
Syntax
<marquee>Contenet </marquee>
Example
<marquee>SVMC</marquee>
38
HTML Scroll Marquee
It is a by default property. It is used to scroll the text from right to left, and
restarts at the right side of the marquee when it is reached to the end of left side.
After the completion of loop text disappears.
Example
<marquee width="100%" behavior="scroll" bgcolor="pink"> SVMC </marquee>
HR tag
The <hr> tag in HTML stands for horizontal rule and is used to insert a
horizontal rule or a thematic break in an HTML page to divide or separate
document sections.
The <hr> tag is an empty tag, and it does not require an end tag.
Syntax
<hr> ...
Example
<h2>HTML</h2>
39
<p>HTML is a language for describing web pages.</p>
<hr/>
<h2>HR Tag </h2>
<p> HR tag is used to draw a horizontal line .<p>
Output:
HTML
HTML is a language for describing web pages.
HR Tag
HR tag is used to draw a horizontal line
Attributes:
The table given below describes the <hr> tag attributes.
Attribute Values Value Description
align left center right Used to specify the alignment of the
horizontal rule.
noshade noshade Used to specify the bar without
shading effect.
size pixels Used to specify the height of the
horizontal rule.
width pixels Used to specify the width of the
horizontal rule.
40
Adding Images Using the < img > Element
Images are added to a site using the < img > element, which has to carry
at least two attributes: the src attribute, indicating the source of the image, and an
alt attribute, which provides a description of the image.
Example
src:
It is used to specify the path to the image.
<img src="URL">
alt:
It is used to specify an alternate text for the image, if the image cannot be
displayed then this alternate text will be displayed.
41
<img alt="text">
Example
<h2>HTML Image Example</h2>
<img src="good_morning.jpg" alt="Good Morning Friends"/>
height:
It is used to specify the height of the image.
<img height="pixels">
width:
It is used to specify the width of the image.
<img width="pixels">
Example
<img src="good_morning.jpg"width="420"height="100" alt="Good Morning Fr
iends"/>
align
The align attribute was created to align an image within the page ,
Align values are
Left, right , top, middle, bottom
<img src=”images/cover.gif” alt=”Book cover” align=”left” />
Border
A border is a line that can appear around an image or other element. The border
attribute was created to specify the width of the border in pixels:
< img src=”images/logo.gif” alt=”Wrox Logo” border=”2” />
42
It is used to specify an image as a server-side image map.
<img ismap>
usemap:
It is used to specify an image as a client-side image map.
<img usemap="#mapname">
longdesc:
It is used to specify a URL to a detailed description of an image.
HTML Links
A webpage can contain various links that take we directly to other pages and
even specific parts of a given page. These links are known as hyperlinks.
Creating Link with <a> Element
A link is specified using HTML tag <a>. This tag is called anchor tag and
anything between the opening <a> tag and the closing </a> tag becomes part of
the link and a user can click that part to reach to the linked document.
Example
<a href = "Document URL" ... attributes-list>Link Text</a>
<body>
<p>Click following link</p>
<a href = "https://www.svmcugi.com"
target = "_self">SVMC</a>
</body>
The target Attribute
43
_blank
1
Opens the linked document in a new window or tab.
_self
2
Opens the linked document in the same frame.
_parent
3
Opens the linked document in the parent frame.
_top
4
Opens the linked document in the full body of the window.
targetframe
5
Opens the linked document in a named targetframe.
44
</html>
45
Unit - IV
Tables
HTML table tag is used to display data in tabular form (row * column). There
can be many columns in a row.
We can create a table to display data in tabular form, using <table> element,
with the help of <tr> , <td>, and <th> elements.
Tag Description
46
Basic Table Elements and Attributes
The <table> Element
The <table> element represents tabular data — that is, information
presented in a two-dimensional table comprised of rows and columns of cells
containing data.
Example
<body>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
</body>
The < table > element can carry the following attributes
• align
• bgcolor
• border
• cellpadding
• cellspacing
• rules
• summary
• width
align attribute
This attribute indicates how the table must be aligned inside the containing
document. It may have the following values:
• left: the table is displayed on the left side of the document;
• center: the table is displayed in the center of the document;
47
• right: the table is displayed on the right side of the document.
bgcolor attribute
The background color of the table. It is a 6-digit hexadecimal RGB code, prefixed
by a '#'.
<table bgcolor="color_name | hex_number | rgb_number">
<table bgcolor="red”>
border attribute
This integer attribute defines, in pixels, the size of the frame surrounding the table.
<table border="1">
rules attribute
The rules attribute is used to indicate which inner borders of the table
should be displayed.
rules=” ruleType ”
48
Summary attribute
This attribute defines an alternative text that summarizes the content of the
table.
width Attribute
The width attribute is used to specify the width of the table, and usually its
value is given in pixels.
width=”500”
Syntax
<tr>.......</tr>
Example
<table border="1">
<tr>
<th>Rank</th>
<th>Country</th>
<th>Total medals</th>
</tr>
</table >
49
justify
char
bgcolor rgb(x,x,x) It defines the background color of the table row.
#xxxxx
color_name
char character It specifies the alignment of content to the character.
charoff number It specifies the number of character the table row
content will be aligned from the character, and which is
specified by char attribute.
valign Top It specifies the vertical alignment of the table row
Middle content.
Bottom
baseline
Syntax
<td>.......</td>
Example
<table>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Price</th>
</tr>
<tr>
<td>Books</td>
<td>5</td>
50
<td>589</td>
</tr>
<tr>
<td>T-shirt</td>
<td>5</td>
<td>3500</td>
</tr>
Syntax
<th>Content....... </th>
Example
<table border="1">
<tr>
<th>Month</th>
<th>Date</th>
</tr>
<tr>
<td>January</td>
<td>20.01.2018</td>
</tr>
<table>
52
HTML Table <caption> tag
HTML <caption> tag is used to add a caption or title of an HTML table. It
should be used inside the <table> element and just after the <table> start tag. A
table may contain only one <caption> element.
Syntax
<caption>Table title...</caption>
Attribute
Tag-specific Attributes
Example
<body>
<h2>Example of Caption tag</h2>
<table width="800">
<caption>Employee Details</caption>
<thead>
<tr>
<th>Sr. No.</th>
<th>Name</th>
<th>Email</th>
</tr>
53
</thead>
<tbody>
<tr>
<td>1.</td>
<td>Ankit Pandey</td>
<td>[email protected]</td>
</tr>
<tr>
<td>2.</td>
<td>Ashvini Kumar</td>
<td>[email protected]</td>
</tr>
<tr>
<td>3.</td>
<td>Swati Sharma</td>
<td>[email protected]</td>
</tr>
</tbody>
</table>
</body>
54
Row Span and Col Span
Row Span
The HTML rowspan attribute define the number of rows a cell of a table
should span in an HTML document. It can only be applied on td or th HTML
element.
Example
Syntax
Following is the syntax −
<tagname rowspan=”number”></tagname>
Example
<table class="tbl">
<tr>
55
<th rowspan="2">Name</th>
<td>Anna</td>
</tr>
<tr>
<td>Paxton</td>
</tr>
<tr>
<th rowspan="3">Address</th>
<td>124 W 7th Street</td>
</tr>
<td>Austin</td>
</tr>
</tr>
<td>Texas, 78702</td>
</tr>
</table>
colspan attribute
The colspan attribute in HTML specifies the number of columns a cell
should span. It allows the single table cell to span the width of more than one cell
or column.
56
Syntax:
<td colspan = "value">table content...</td>
Attribute Values:
Attribute Values Description
number It specifies how many columns a cell
should cover. When set to
`colspan=”0″`, it instructs the browser
to expand the cell to the last column of
the table section (thead, tbody, or
tfoot).
Example
<table>
<tr>
<th>Name</th>
57
<th>Expense</th>
</tr>
<tr>
<td>Arun</td>
<td>$10</td>
</tr>
<tr>
<td>Priya</td>
<td>$8</td>
</tr>
<tr>
<td colspan="2">Sum: $18</td>
</tr>
</table>
<tr>
<td>Arun</td>
<td>$10</td>
</tr>
<tr>
<td>Priya</td>
<td>$8</td>
</tr>
</table>
Table Cellpadding
Cellpadding is the attribute that defines the space in a cell between the cell content
and its border.
Syntax
<table cellpadding="value" >.....</table>
Type of value
Type of value of HTML cellpadding attribute is pixel, percent or
multilength(i.e. relative length).
Value
59
A length in pixels, percent or a relative length.
Default value
There is no default value of HTML cellpadding attribute.
Example 1:
Table with Cellpadding set as 15 pixels
<table border="1"
cellpadding="15">
<caption>Book</caption>
<tr>
<th>NAME</th>
<th>AUTHOR</th>
<th>GENRE</th>
</tr>
<tr>
<td>The Kite Runner</td>
<td>Khaled Hosseini</td>
<td>Historical fiction Drama</td>
</tr>
</table>
Example 2:
Table with Default Cellpadding (1 pixel)
<table border="1">
<caption>Book</caption>
60
<tr>
<th>NAME</th>
<th>AUTHOR</th>
<th>GENRE</th>
</tr>
<tr>
<td>The Kite Runner</td>
<td>Khaled Hosseini</td>
<td>Historical fiction Drama</td>
</tr>
</table>
61
Add a Caption to a Table
To insert a caption into a table, use the <caption> tag.
<table>
<caption></caption>
<tr> </tr>
</table>
Example
<body>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Priya</td>
<td>Sharma</td>
<td>24</td>
</tr>
<tr>
<td>Arun</td>
<td>Singh</td>
<td>32</td>
</tr>
<tr>
<td>Sam</td>
<td>Watson</td>
<td>41</td>
62
</tr>
</table>
</body>
63
Unit - V
HTML Frames
Introducing Frameset
HTML frames are used to divide the browser window into multiple sections
where each section can load a separate HTML document.
A collection of frames in the browser window is known as a frameset. The
window is divided into frames in a similar way the tables are organized: into rows
and columns.
<frameset> element
The <frameset> element contains one or more frame elements. It is used to
specify the number of rows and columns in frameset with their pixel of spaces.
Syntax:
<frameset cols = "pixels|%|*">
<frameset> Attribute
There are several frameset attributes are given below:
• Cols
• Rows
64
• Border
• framespacing
cols: The cols attribute is used to create vertical frames in a web browser. This
attribute is basically used to define the no. of columns and their size inside the
frameset tag.
<frameset cols = "20%, 60%, 20%">
<frame name = "top" src = "attr1.png" />
<frame name = "main" src = "gradient3.png" />
<frame name = "bottom" src = "col_last.png" />
</frameset>
rows: The rows attribute is used to create horizontal frames in the web browser.
This attribute is used to define the no. of rows and their size inside the frameset tag.
<frameset rows = "20%, 60%, 20%">
<frame name = "top" src = "attr1.png" />
<frame name = "main" src = "gradient3.png" />
<frame name = "bottom" src = "col_last.png" />
</frameset>
border: This attribute of frameset tag defines the width of the border of each frame
in pixels. Zero value is used for no border.
<frameset border = “2”>
framespacing: This attribute of frameset tag is used to specify the amount of
spacing between the frames in a frameset. This can take any integer value as a
parameter which basically denotes the value in pixel.
<frameset rows="*" cols="200, *" framespacing="30">
65
<frame> Element
The <frame> HTML element defines a particular area in which another
HTML document can be displayed.
<frame>Attribute
▪ src Attribute
▪ name Attribute
▪ frameborder Attribute
▪ marginwidth and marginheight Attributes
▪ noresize Attribute
▪ scrolling Attribute
▪ longdesc Attribute
src Attribute
This attribute in frame tag is basically used to define the source file that
should be loaded into the frame.The value of src can be any url.
Example:
<frame name = "left" src = "/html/left.htm" />
Name Attribute
It is used to assign the name to the frame.
<frame name = "text">
<frame name = "SVMC">
frameborder Attribute
frameborder attribute is to specify whether or not to display a border around
a frame.
The value of this attribute can be set to “1” or “0”.
Example
66
<frame frameborder="value" >.....</frame>
<frame src="frame_left.htm" frameborder="0" />
marginwidth Attribute
This attribute in frame tag is used to specify width of the spaces in pixels
between the border and contents of left and right frame.
Example:
<frame marginwidth="20">
Marginheight Attribute
This attribute in frame tag is used to specify height of the spaces in pixels
between the border and contents of top and bottom frame.
Example:
<frame marginheight="20">
Scrollbar Attribute
To control the appearance of scroll bar in frame use scrollbar attribute in
frame tag. This is basically used to control the appearance of scrollbar. The value of
this attribute can be yes, no, auto.
Example
<frame scrollbar="no">
noresize attribute
noresize attribute is used to specify that the frame element can not be resize
by the user. This type of attribute is used to lock the size of the frame element.
<frameset cols="30%, 40%, 30%">
<frame name="top" src="attr1.png" noresize="noresize"/>
</frameset>
longdesc Attribute
longdesc Attribute is used to specify a page which contains the long
description of the content of the frame.
67
Syntax:
<frame longdesc="URL">
Example
<frameset cols="50%,50%">
<frame src="frame_a.htm" longdesc="w3s.txt">
<frame src="frame_b.htm">
</frameset>
Nesting Framesets
Nesting framesets involves including one frameset within another, which
can provide more flexibility in designing complex layouts.
1. Start by defining the outer frameset using the < frameset> tag.
2. Within the outer frameset, define the rows or columns using the rows or
cols attribute respectively.
3. The rows attribute specifies the height of each row as a comma-separated
list of values or percentages.
4. The cols attribute specifies the width of each column in a similar manner.
5. Inside each row or column, define another frameset using the
68
< frameset> tag.
6. Repeat this process to include as many nested framesets as required.
7. Finally, include the < frame> or < iframe> tags within the innermost
framesets to display the desired content.
Example
<frame src="frame1.html">
<frame src="frame2.html">
</frameset>
<frame src="frame3.html">
<frame src="frame4.html">
</frameset>
</frameset>
Noframe tag
The <noframes> tag is the backup for those browsers that does not support
frames. This tag can contains the entire element that can be placed in <body> tag.
It is used to create link with the non-frame set version of any website where
you want to display a message to the user.
This <noframes> tag is not supported in HTML5.
Syntax:
<noframes> Statement for the user </noframes>
69
Browser compatibility
The HTML noframes tag is supported by different types of browsers.
• Chrome
• Firefox
• Opera
• Safari
• Internet Explorer
Example
<!DOCTYPE html>
<html>
<frameset cols="25%,50%,25%">
<frame src="frame_a.htm">
<frame src="frame_b.htm">
<frame src="frame_c.htm">
<noframes>Sorry, your browser does not handle frames!</noframes>
</frameset>
</html>
70
HTML Form
An HTML form is a section of a document which contains controls such as text
fields, password fields, checkboxes, radio buttons, submit button, menus etc.
An HTML form facilitates the user to enter data that is to be sent to the server
for processing such as name, email address, password, phone number, etc. .
71
HTML <input> element
The HTML <input> element is fundamental form element. It is used to create
form fields, to take input from user. We can apply different input filed to gather
different information form user.
Attributes
Attributes Descriptions
type It is used to specify the type of the input
element. Its default value is text.
value It is used to specify the value of the
input element.
placeholder Placeholder attribute is used to specify
hint that describes the expected value of
an input field.
name It is used to specify the name of the
input element.
alt It is used to provide alternate text for
the user, if they cannot view the image.
autofocus It specifies that an element should
automatically get focus when the page
loads.
checked It specifies that an element should be
pre-selected (checked) when the page
loads.
disabled The disabled attribute specifies that the
element should be disabled
max It is used to specify the maximum value
for an < input > element.
required It specifies that an input field must be
filled out before submitting the form.
readonly It specifies that an input field is read-
only. A read-only input field cannot be
modified.
align It is used to specifies the alignment of
an image input.
<input type=”text”>
The HTML <input type=”text”> is used to define a single-line text field .
Syntax
72
<input type="text">
Example
<body>
<form>
Enter your name <br>
<input type="text" name="username">
</form>
</body>
<input type=”password”>
The HTML <input type=”password”> is used to specify the password field
of input tag.
Example
<input type="password" id="mypasswd">
73
Radio Button Control
The radio button is used to select one option from multiple options. It is used for
selection of gender, quiz questions etc.
Example
<form>
<label for="gender">Gender: </label>
<input type="radio" id="gender" name="gender" value="male"/>Male
<input type="radio" id="gender" name="gender" value="female"/>Fe
male <br/>
</form>
Checkbox Control
The checkbox control is used to check multiple options from given checkboxes.
<form>
Hobby:<br>
<input type="checkbox" id="cricket" name="cricket" value="cricket"/>
<label for="cricket">Cricket</label> <br>
74
<input type="checkbox" id="football" name="football" value="football"/>
<label for="football">Football</label> <br>
<input type="checkbox" id="hockey" name="hockey" value="hockey"/>
<label for="hockey">Hockey</label>
</form>
Syntax:
<input type="submit" value="submit">
Example
<form>
<label for="name">Enter name</label><br>
<input type="text" id="name" name="name"><br>
<label for="pass">Enter Password</label><br>
<input type="Password" id="pass" name="pass"><br>
<input type="submit" value="submit">
</form>
75
HTML <select> Tag
The <select> tag in HTML is used to create a drop-down list. The <select>
tag contains <option> tag to display the available option of drop-down list.
Syntax:
<select>
<option>
</option>
...
</select>
<select>
<option value="By the way">BTW</option>
<option value="Talk to you later">TTYL</option>
<option value="To be honest">TBH</option>
<option value=" I don’t know">IDK</option>
</select>
Example
<form>
<fieldset>
76
<legend>User personal information</legend>
<label>Enter your full name</label><br>
<input type="text" name="name"><br>
<label>Enter your email</label><br>
<input type="email" name="email"><br>
<label>Enter your password</label><br>
<input type="password" name="pass"><br>
<label>confirm your password</label><br>
<input type="password" name="pass"><br>
<br><label>Enter your gender</label><br>
<input type="radio" id="gender" name="gender" value="male"/>Male <br>
<input type="radio" id="gender" name="gender" value="female"/>Female <
br/>
<input type="radio" id="gender" name="gender" value="others"/>others <br/>
<br>Enter your Address:<br>
<textarea></textarea><br>
<input type="submit" value="sign-up">
</fieldset>
</form>
77