IWT UNIT - 2 HTML RGPV
IWT UNIT - 2 HTML RGPV
UNIT 02
HTML: Basics of HTML, formatting and fonts, commenting code, color,
hyperlink, lists, tables, images, forms, XHTML, Meta tags, Character entities,
frames and frame sets, Browser architecture and Web site structure. Overview
and features of HTML5
Hypertext refers to the way in which Web pages (HTML documents) are
linked together. Thus, the link available on a webpage is called Hypertext.
As its name suggests, HTML is a Markup Language which means you use
HTML to simply "mark-up" a text document with tags that tell a Web
browser how to structure it to display.
Originally, HTML was developed with the intent of defining the structure of
documents like headings, paragraphs, lists, and so forth to facilitate the sharing
of scientific information between researchers.
Now, HTML is being widely used to format web pages with the help of different
tags available in HTML language.
<!DOCTYPE html>
<html>
<head>
<title>This is document title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Document content goes here.....</p>
</body>
</html>
HTML Tags
As told earlier, HTML is a mark-up language and makes use of various tags to
format the content. These tags are enclosed within angle braces <Tag Name>.
Tag Description
<!DOCTYPE...> : This tag defines the document type and HTML version.
<html> :This tag encloses the complete HTML document and mainly
comprises of document header which is represented by <head>...</head>
and document body which is represented by <body>...</body> tags.
<head> This tag represents the document's header which can keep other
HTML tags like <title>, <link> etc.
<title> The <title> tag is used inside the <head> tag to mention the
document title.
<body> This tag represents the document's body which keeps other HTML
tags like <h1>, <div>, <p> etc.
<h1> This tag represents the heading.
<p> This tag represents a paragraph.
Heading Tags
Any document starts with a heading. You can use different sizes for your
headings. HTML also has six levels of headings, which use the elements H1, H2,
H3, H4, H5. While displaying any heading, browser adds one line before and one
line after that heading.
Example
<!DOCTYPE html>
<html>
<head>
<title>Heading Example</title>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
OUTPUR RESULTS OH HEADING tags
The <p> tag offers a way to structure your text into different paragraphs. Each
paragraph of text should go in between an opening <p> and a closing </p> tag as
shown below in the
example:
<!DOCTYPE html>
<html>
<head>
<title>Paragraph Example</title>
</head>
<body>
<p>Here is a first paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>
OUTPUT:
The <br /> tag has a space between the characters br and the forward slash. If you
omit this space, older browsers will have trouble rendering the line break, while
if you miss the forward slash character and just use <br> it is not valid in
XHTML.
Example
<!DOCTYPE html>
<html>
<head>
<title>Line Break Example</title>
</head>
<body>
<p>Hello<br />
You delivered your assignment on time.<br />
Thanks<br />
Sachin </p>
</body>
Thanks
Sachin
Again <hr /> tag is an example of the empty element, where you do not need
opening and closing tags, as there is nothing to go in between them.
The <hr /> element has a space between the characters hr and the forward slash.
If you omit this space, older browsers will have trouble rendering the horizontal
line, while if you miss the forward slash character and just use <hr> it is not valid
in XHTML
Example
<!DOCTYPE html>
<html>
<head>
<title>Preserve Formatting Example</title>
</head>
<body>
<pre>
function testFunction( strText ){
alert (strText)
}
</pre>
</body>
</html>
Try using the same code without keeping it inside <pre>...</pre> tags
In the previous chapter, you learned about the HTML style attribute.
HTML also defines special elements for defining text with a special
meaning.
HTML uses elements like <b> and <i> for formatting output, like bold or
italic text.
Formatting elements were designed to display special types of text:
o <b> - Bold text
o <strong> - Important text
o <i> - Italic text
o <em> - Emphasized text
o <mark> - Marked text
o <small> - Small text
o <del> - Deleted text
o <ins> - Inserted text
o <sub> - Subscript text
o <sup> - Superscript text
The HTML <b> element defines bold text, without any extra importance.
Example
The HTML <strong> element defines strong text, with added semantic
"strong" importance.
Example
The HTML <i> element defines italic text, without any extra importance.
Example
The HTML <em> element defines emphasized text, with added semantic
importance.
Example
Note: Browsers display <strong> as <b>, and <em> as <i>. However, there
is a difference in the meaning of these tags: <b> and <i> defines bold and
italic text, but <strong> and <em> means that the text is "important".
Example
Example
Example
Example
Example
Example
Notice that there is an exclamation point (!) in the opening tag, but not in the
closing tag.
Note: Comments are not displayed by the browser, but they can help document
your HTML source code.
With comments you can place notifications and reminders in your HTML:
Example
<!DOCTYPE html>
<html>
<body>
-->
</body>
</html>
Tomato
Orange
DodgerBlue
MediumSeaGreen
Gray
SlateBlue
Violet
Hue
Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, 240
is blue.
Saturation
Saturation is a percentage value; 0% means a shade of gray and 100% is the
full color.
Lightness
Lightness is also a percentage; 0% is black, 100% is white.
Example
<style>
div {
background-color: hsl(180, 50%, 50%);
color: hsl(0, 0%, 100%);
}
</style>
CMYK Colors
When writing in HTML, the <font> tag was an inline element used to change
certain qualities of a block of text on a web page. It was useful for changing a
font's size, face, and color. The following sections contain information about this
tag, including an example of it in use, as well as related attributes and browser
compatibility.
The <font> tag is not supported going forward; CSS should be used instead.
example
Example result
I am a sentence!
Attribute Description
<html>
<head>
<title>cist</title>
</head>
<body>
<p>
</p>
<p>
</p>
<p>
</p>
</body>
</html>
A webpage can contain various links that take you directly to other pages and
even specific parts of a given page. These links are known as hyperlinks.
Hyperlinks allow visitors to navigate between Web sites by clicking on words,
phrases, and images. Thus you can create hyperlinks using text or images
available on a webpage.
Note − I recommend you to go through a short tutorial on Understanding URL
Linking Documents
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. Following is the simple
syntax to use <a> tag.
<a href = "Document URL" ... attributes-list>Link Text</a>
Example
Let's try following example which links http://www.t corporatecollege.com at your page
−
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
</head>
<body>
<p>Click following link</p>
<a href = "https://www.corporatecollege.com" target = "_self"> corporate college </a>
</body>
</html>
1
_blank
Opens the linked document in a new window or tab.
2
_self
Opens the linked document in the same frame.
3
_parent
Opens the linked document in the parent frame.
4
_top
Opens the linked document in the full body of the window.
5
targetframe
Opens the linked document in a named targetframe.
<body>
<p>Click any of the following links</p>
<a href = "/html/index.htm" target = "_blank">Opens in New</a> |
<a href = "/html/index.htm" target = "_self">Opens in Self</a> |
<a href = "/html/index.htm" target = "_parent">Opens in Parent</a> |
<a href = "/html/index.htm" target = "_top">Opens in Body</a>
</body
</html>
OUTPUT WINDOW
HTML offers web authors three ways for specifying lists of information. All lists must
contain one or more list elements. Lists may contain −
<ul> − An unordered list. This will list items using plain bullets.
<ol> − An ordered list. This will use different schemes of numbers to list your items.
<dl> − A definition list. This arranges your items in the same way as they are arranged in
a dictionary.
<!DOCTYPE html>
<html>
<head>
<title>HTML Unordered List</title>
</head>
<body>
<ul>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
This will produce the following result −
Beetroot
Ginger
Potato
Radish
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
Example
Beetroot
Ginger
Potato
Radish
If you are required to put your items in a numbered list instead of bulleted, then
HTML ordered list will be used. This list is created by using <ol> tag. The
numbering starts at one and is incremented by one for each successive ordered
list element tagged with <li>.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
1. Beetroot
2. Ginger
3. Potato
4. Radish
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = "I">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
I. Beetroot
II. Ginger
III. Potato
IV. Radish
The HTML tables allow web authors to arrange data like text, images, links, other
tables, etc. into rows and columns of cells.
The HTML tables are created using the <table> tag in which the <tr> tag is used
to create table rows and <td> tag is used to create data cells. The elements under
<td> are regular and left aligned by default
Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML Tables</title>
</head>
<body>
<table border = "1">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
<head>
<title>HTML Table Header</title>
</head>
<body>
<table border = "1">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</body>
</html>
<head>
<title>HTML Table Colspan/Rowspan</title>
</head>
<body>
<table border = "1">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr>
<td rowspan = "2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
</tr>
<tr>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
</tr>
<tr>
<td colspan = "3">Row 3 Cell 1</td>
</tr>
</table>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Background</title>
</head>
<body>
<table border = "1" bordercolor = "green" bgcolor = "yellow">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr>
<td rowspan = "2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
</tr>
<tr>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
</tr>
<tr>
<td colspan = "3">Row 3 Cell 1</td>
</tr>
</table>
</body>
</html>
<head>
<title>HTML Table Width/Height</title>
</head>
<body>
<table border = "1" width = "400" height = "150">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Caption</title>
</head>
<body>
<table border = "1" width = "100%">
<caption>This is the caption</caption>
<tr>
<td>row 1, column 1</td><td>row 1, columnn 2</td>
</tr>
<tr>
<td>row 2, column 1</td><td>row 2, columnn 2</td>
</tr>
</table>
</body>
</html>
This will produce the following result –
HTML Forms are required, when you want to collect some data from the site visitor.
For example, during user registration you would like to collect information such as
name, email address, credit card, etc.
A form will take input from the site visitor and then will post it to a back-end application
such as CGI, ASP Script or PHP script etc. The back-end application will perform
required processing on the passed data based on defined business logic inside the
application.
There are various form elements available like text fields, textarea fields, drop-down
menus, radio buttons, checkboxes, etc.
The HTML <form> tag is used to create an HTML form and it has following syntax −
Example
Here is a basic example of a single-line text input used to take first name and last
name −
<!DOCTYPE html>
<html>
<head>
<title>Text Input Control</title>
</head>
<body>
<form >
First name: <input type = "text" name = "first_name" />
<br>
Last name: <input type = "text" name = "last_name" />
</form>
</body>
</html>
Example
Here is a basic example of a single-line password input used to take user password
−
<!DOCTYPE html>
<html>
<head>
<title>Password Input Control</title>
</head>
<body>
<form >
User ID : <input type = "text" name = "user_id" />
<br>
Password: <input type = "password" name = "password" />
</form>
</body>
</html>
Example
Here is a basic example of a multi-line text input used to take item description −
<!DOCTYPE html>
<html>
<head>
<title>Multiple-Line Input Control</title>
</head>
<body>
<form>
Description : <br />
<textarea rows = "5" cols = "50" name = "description">
Enter description here...
</textarea>
</form>
</body>
</html>
Example
Here is an example HTML code for a form with two checkboxes −
<!DOCTYPE html>
<html>
<head>
<title>Checkbox Control</title>
</head>
<body>
<form>
<input type = "checkbox" name = "maths" value = "on"> Maths
<input type = "checkbox" name = "physics" value = "on"> Physics
</form>
</body>
</html>
This will produce the following result −
Example
Here is example HTML code for a form with two radio buttons –
<!DOCTYPE html>
<html>
<head>
<title>Radio Box Control</title>
</head>
<body>
<form>
<input type = "radio" name = "subject" value = "maths"> Maths
<input type = "radio" name = "subject" value = "physics"> Physics
</form>
</body>
</html>
Example
Here is example HTML code for a form with one drop down box
<!DOCTYPE html>
<html>
<head>
<title>Select Box Control</title>
</head>
<body>
<form>
<select name = "dropdown">
<option value = "Maths" selected>Maths</option>
<option value = "Physics">Physics</option>
</select>
</form>
</body>
</html>
This will produce the following result −
Example
Here is example HTML code for a form with one file upload box −
<!DOCTYPE html>
<html>
<head>
<title>File Upload Box</title>
</head>
<body>
<form>
<input type = "file" name = "fileupload" accept = "image/*" />
</form>
</body>
</html>
This will produce the following result −
1
submit
This creates a button that automatically submits a form.
2
reset
This creates a button that automatically resets form controls to their initial values.
3
button
This creates a button that is used to trigger a client-side script when the user clicks that
button.
4
image
This creates a clickable button but we can use an image as background of the button.
<!DOCTYPE html>
<html>
<head>
<title>File Upload Box</title>
</head>
<body>
<form>
<input type = "submit" name = "submit" value = "Submit" />
<input type = "reset" name = "reset" value = "Reset" />
<input type = "button" name = "ok" value = "OK" />
<input type = "image" name = "imagebutton" src = "/html/images/logo.png" />
</form>
</body>
</html>
This will produce the following result −
HTML processors must support following five special characters listed in the
table that follows.
SYMBOL CODE NAME
  space
# # number
$ $ dollar
% % percent
* * asterisk
, , comma
- - minus
. . period
/ / slash
0 0 zero
1 1 one
2 2 two
3 3 three
4 4 four
5 5 five
6 6 six
7 7 seven
8 8 eight
9 9 nine
: : colon
; ; semicolon
@ @ at sign
A A
B B
C C
D D
E E
F F
H H
I I
J J
K K
L L
M M
N N
O O
P P
Q Q
R R
S S
T T
U U
V V
W W
X X
Y Y
Z Z
\ \ backslash
_ _ underscore
a a
b b
d d
e e
f f
g g
h h
i i
j j
k k
l l
m m
n n
o o
p p
q q
r r
s s
t t
u u
v v
w w
x x
y y
z z
~ ~ tilde
If you want to write <div id = "character"> as a code then you will have to write as
follows –
<!DOCTYPE html>
<html>
<head>
<title>HTML Entities</title>
</head>
<body>
<div id = "character">
</body>
</html>
This will produce the following result –
<div id = "character">
Attribute Description
httpequiv Used for http response message headers. For example, http-
equiv can be used to refresh the page or to set a cookie.
Values include content-type, expires, refresh and set-cookie.
Example
Hello HTML5!
Example
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
<meta name="description" content="Learning about Meta Tags." />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
With frames, you can display more than one Web page in the same browser
window.
Examples
Vertical frameset This example demonstrates how to make a vertical frameset
with three different documents.
Horizontal frameset This example demonstrates how to make a horizontal
frameset with three different documents.
How to use the <noframes> tag This example demonstrates how to use the
<noframes> tag.
Frames
With frames, you can display more than one HTML document in the same
browser window. Each HTML document is called a frame, and each frame is
independent of the others.
The disadvantages of using frames are:
The web developer must keep track of more HTML documents
It is difficult to print the entire page
In the example below we have a frameset with two columns. The first column is
set to 25% of the width of the browser window. The second column is set to 75%
of the width of the browser window. The HTML document "frame_a.htm" is put
into the first column, and the HTML document "frame_b.htm" is put into the
second column:
<frameset cols="25%,75%">
<frame src="frame_a.htm">
<frame src="frame_b.htm">
</frameset>
Frame Tags
Tag Description
<frameset> Defines a set of frames
<frame> Defines a sub window (a frame)
<noframes> Defines a no frame section for browsers that do
not handle frames
<iframe> Defines an inline sub window (frame)
Web browser can show text, audio, video, animation and more. It is the
responsibility of a web browser to interpret text and commands contained in the
web page.
Earlier the web browsers were text-based while now a days graphical-based or
voice-based web browsers are also available. Following are the most common
web browser available today:
Browser Vendor
Safari Apple
Controller works as a control unit in CPU. It takes input from the keyboard or mouse,
interpret it and make other services to work on the basis of input it receives.
Interpreter receives the information from the controller and execute the instruction
line by line. Some interpreter are mandatory while some are optional For example,
HTML interpreter program is mandatory and java interpreter is optional.
Client Program describes the specific protocol that will be used to access a particular
service. Following are the client programs tat are commonly used:
HTTP
SMTP
FTP
NNTP
POP
Saving Webpage
You can save web page to use in future. In order to save a webpage, follow the steps
given below:
Click File > Save As. Save Webpage dialog box appears.
Choose the location where you want to save your webpage from save in: list box. Then
choose the folder where you want to save the webpage.
Specify the file name in the File name box.
Select the type from Save as type list box.
o Webpage, complete
o Web Archive
o Webpage HTML only
o Text File
From the encoding list box, choose the character set which will be used with your
webpage. By default, Western European is selected.
Click save button and the webpage is saved.
In Add Favourites dialog box, the Name: text box will contains the name of the web page
that you want to add to favourites.
Click the Create in button, Favourites folder will appear. Move to the folder where you
want to store the favourites by clicking on the folder name.
Now click OK button to save the favourites.
Browser Support
The latest versions of Apple Safari, Google Chrome, Mozilla Firefox, and Opera
all support many HTML5 features and Internet Explorer 9.0 will also have
support for some HTML5 functionality.
The mobile web browsers that come pre-installed on iPhones, iPads, and Android
phones all have excellent support for HTML5.