Unit 1 HTML
Unit 1 HTML
Technology
Need of Subject
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html >
Example Explained
<!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>
Basic Tags
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>, and <h6>. While displaying any
heading, browser adds one line before and one line after
that heading.
Example 3
<!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>
Paragraph Tag
<!DOCTYPE html>
<html>
<head>
<title>Line Break Example</title>
</head>
<body><p>Hello<br />
You delivered your assignment ontime.<br />
Thanks<br />
Mahnaz</p>
</body>
</html>
Output
Hello
You delivered your assignment ontime.
Thanks
Mahnaz
HTML Tags
The first tag in a pair is the start tag, the second tag is the end tag
The end tag is written like the start tag, but with a slash before the
tag name
Link Tag
Html Links : Html links are defined with the <a> tag
Example : <html>
<body>
<a href="http://www.gmail.com">Gmail</a>
</body>
</html>
</body>
</html>
O/P:
Image mapping
<!DOCTYPE html>
<html>
<body>
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
</body>
</html>
Output
HTML RULES
HTML Rules (Lines) :
The <hr /> tag is used to create an horizontal rule (line).
Example:
<html><body>
O/P :
Exnora
<h3>Exnora</h3>
<hr /> Safety Exnora
<h3>Safety Exnora</h3>
</body></html>
HTML COMMENTS
HTML Comments :
Comments can be inserted in the HTML code to make
it more readable and understandable. Comments are ignored by the
browser and are not displayed.
Syntax : <!-- some text →
Example :
<html><body> O/P :
<html><body>
<b>Confidence</b><br />
<big>Hardwork</big><br />
<i>Preseverance</i><br />
<code>Samsung CRT</code><br /> Implement it as a Exercise
This is<sub> subscript</sub><br /> (Practical)
This is<sup> superscript</sup>
</body></html>
HTML STYLE ATTRIBUTES
Tags Description
Attributes Description
<body style="background-color:yellow">
<table border="1">
<tr> <td>row 1, cell 1</td> row1,cell1 row1,cell2
<td>row 1, cell 2</td> </tr>
<tr> <td>row 2, cell 1</td>
row2,cell1 row2,cell2
<td>row 2, cell 2</td></tr>
</table>
TABLE FEATURES
1.Table with a caption :
<caption>My Caption</caption>
<th colspan="2">Telephone</th>
<th rowspan="2">Telephone:</th>
3.Cell padding :
4.Cell spacing :
Ordered Lists :
An ordered list is also a list of items. The list items are marked with
numbers.
An ordered list starts with the <ol> tag. Each list item starts with the <li>
tag.
Unordered Lists :
An unordered list is a list of items. The list items are marked with bullets
(typically small black circles).
An unordered list starts with the <ul> tag. Each list item starts with the
<li> tag.
Definition Lists :
A definition list is not a list of single items. It is a list of items (terms),
with a description of each item (term).
A definition list starts with a <dl> tag (definition list).
Each term starts with a <dt> tag (definition term).
Each description starts with a <dd> tag (definition description).
Think Positve 1.Fail Success
Fail First,
Never Depressed 2.Work Hard Happy
Keep Smiling 3.Win Smile Always
4.Teach
Centering Content
You can use <center> tag to put any content in the center of
the page or any table cell.
Output
<!DOCTYPE html>
<html>
<head>
<title>Horizontal Line Example</title>
</head>
<body><p>This is paragraph one and should be on top</p>
<hr />
<p>This is paragraph two and should be at bottom</p>
</body>
</html>
Output
Preserve Formatting
Sometimes you want your text to follow the exact format of how it
is written in the HTML document. In those cases, you can use the
preformatted tag <pre>.
Any text between the opening <pre> tag and the closing </pre> tag
will preserve the formatting of the source document.
Output
Nonbreaking Spaces
<!DOCTYPE html>
<html>
<head>
<title>Nonbreaking Spaces Example</title>
</head>
<body>
<p>An example of this technique appears in the movie
"12 Angry Men."</p>
</body>
</html>
Output
<!DOCTYPE html>
<html>
<head>
<title>Set Image Alignment</title>
</head>
<body> <p>Setting image Alignment</p>
<img src="/html/images/test.png" alt="Test Image"
border="3" width="150" height="100" align="right"/>
</body>
</html>
Output
HTML Text Links
_top Opens the linked document in the full body of the window.
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
<base href="https://www.tutorialspoint.com/">
</head>
<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
<!DOCTYPE html>
<html>
<head>
<title>Base Tag Example</title>
<base href="https://www.tutorialspoint.com/">
</head>
<body>
<p>Click following link</p>
<a href="/html/index.htm" target="_blank">HTML Tutorial</a>
</body>
</html>
You can set colors of your links, active links and visited links using link,
alink and vlink attributes of <body> tag.
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
<base href="https://www.tutorialspoint.com/"></head>
<body alink="#54A250" link="#040404" vlink="#F40633"><p>Click
following link</p>
<a href="/html/index.htm" target="_blank" >HTML Tutorial</a>
</body>
</html>
HTML Image Links
<!DOCTYPE html>
<html>
<head>
<title>Image Hyperlink Example</title> </head>
<body>
<p>Click following link</p>
<a href="https://www.tutorialspoint.com" target="_self">
<img src="/images/logo.png" alt="Tutorials Point"
border="0"/> </a>
</body></html>
Assignment
FRAME
64
Frame template
<html>
<frameset …>
</frameset>
</html>
Frameset attributes
69
COLS,ROWS
-a comma-separated list of pixel values, percentages
values
-Frameset entries should always specify at least two
rows or columns
<frameset rows=“50,10%”>
......
</frameset>
70
<html>
<body bgcolor="red">
atul
</boby>
</html>
a.html
71
72
<html>
<body bgcolor="GREEN">
hello
</body>
</html>
b.html
73
74
<html>
<frameset rows="50%,40%,10%">
<frame src="a.html">
<frame src="b.html">
<frame src="a.html">
</frameset>
</html>
75
<html> 76
<frameset rows="50%,20%,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
</html>
77
78
<html>
<frameset rows="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
</html>
79
80
<html>
<frameset cols="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
</html>
81
82
<html>
<frameset rows="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
<frameset cols="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
</html>
83
84
<html>
<frameset rows="*,*,*">
<frameset cols="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
</frameset>
</html>
85
<html>
<frameset rows="*,*,*">
86
<frameset cols="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
<frame src="a.html">
<frame src="a.html">
</frameset>
</html>
87
<html>
<frameset rows="*,*,*" > 88
<frameset cols="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
<frameset cols="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
<frameset cols="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
</frameset>
</html>
89
Frameset attribute:frameborder
90
</frameset>
<frame src="a.html">
<frame src="a.html">
</frameset>
</html>
96
<html>
<frameset rows="*,*,*" framespacing="25"
97
frameborder="1">
<frameset cols="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
<frame src="a.html">
<frame src="a.html">
</frameset>
</html>
98
99
<html>
<frameset rows="*,*,*" framespacing="25"
bordercolor="green">
<frameset cols="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
<frame src="a.html">
<frame src="a.html">
</frameset>
</html>
100
101
<html>
<frameset rows="*,*,*" framespacing="25"
bordercolor="green" >
<frameset cols="*,*,*">
<frame src="a.html" noresize>
<frame src="a.html">
<frame src="a.html">
</frameset>
<frame src="a.html">
<frame src="a.html">
</frameset>
</html>
102
103
<html>
<frameset rows="*,*,*" framespacing="5" bordercolor="green" >
<frameset cols="*,*,*">
<frame src="a.html" marginwidth="150">
<frame src="a.html">
<frame src="a.html">
</frameset>
<frame src="a.html">
<frameset cols="*,*,*">
<frame src="a.html">
<frame src="a.html">
<frame src="a.html">
</frameset>
</frameset>
</html>
104
105
<html>
<frameset rows="*,*,*" framespacing="5"
bordercolor="green" >
<frameset cols="*,*,*">
<frame src="a.html" marginheight="50">
<frame src="a.html">
<frame src="a.html">
</frameset>
<frame src="a.html">
<frame src="a.html">
</frameset>
</html>
106
107
<html> 108
<HTML>
<BODY>
< A H R E F = " B . H T M L " > AT U L < / A >
</BODY>
</HTML>
113
114
115
<html>
<frameset rows="50,50%">
<frame src="ftable.html">
<frame name="main" >
</frameset>
</html>
(nest.html)
116
<html>
<table border="5" align="center"
width="60%">
<tr>
<th> <a href="f:\frame\a.html" target="main"
>a</a></th>
<th> <a href="f:\frame\b.html"
target="main">b</a></th>
</table>
</html> (ftable.html)
117
118
119
120
DIFFERENCE BETWEEN DIV AND FRAME
A <div> is a generic container element for grouping and styling, whereas a <frame> creates
divisions within a web page and should be used within the <frameset> tag.
<DIV >
The <div> tag defines a division or a section in an HTML document.
The <div> tag is used to group block-elements to format them with CSS.
Tips and Notes
Tip: The <div> element is very often used together with CSS, to layout a web page.
Note: By default, browsers always place a line break before and after the <div> element.
However, this can be changed with CSS.
<FRAME>
The <frame> tag is not supported in HTML5.
The <frame> tag defines one particular window (frame) within a <frameset>.
Each <frame> in a <frameset> can have different attributes, such as border, scrolling, the ability
to resize, etc.
Note: If you want to validate a page containing frames, be sure the <DOCTYPE> is set to either
"HTML Frameset DTD" or "XHTML Frameset DTD".
HTML - <span> Tag
There is a difference between the span tag and the div tag.
The span tag is used with inline elements whilst the div
tag is used with block-level content.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML span Tag</title>
</head>
<body> <p>This is a paragraph <span style = "color:#FF0000;">
This is a paragraph</span>This is a paragraph</p>
<p><span style = "color:#8866ff;"> This is another
paragraph</span></p>
</body> </html>
iframe
<!DOCTYPE html>
<html>
<head>
<title>HTML Iframes</title>
</head>
<body>
<p>Document content goes here...</p>
<iframe src = "https://www.tutorialspoint.com/index.htm" width =
"100%"></iframe>
<p>Document content also go here...</p>
</body>
</html>
Output
DHTML
1:Name
2:Action
3:Method
Name is a property or attributes associated with each
object used 130
in a form.
Input:
The most used form tag is the <input > tag .The
type of input is specified with the type attributes.
135
<html>
<form>
First name:
<input type="text" name="fname">
<br>
Last name:
<input type="text" name="lname">
</form>
</html>
136
137
<html>
<form>
First name :
<input type="text" name="fname" size="50">
<br>
Last name:
<input type="text" name="lname">
</form>
</html>
140
141
<html>
<form>
First name :
<input type="text" name="fname" size="50“
maxlength=“3”>
<br>
Last name:
<input type="text" name="lname">
</form>
142
143
Password:
a password textfield in which each keystroke
appears as an dot.
144
<html>
<form>
First name :
<input type="password" name="fname" size="50"
maxlength="3">
<br>
Last name:
<input type="text" name="lname">
</form>
145
146
Button:
An HTML button elements is commonly used
form object. It is generally used to trigger
appropriate form level processing.
Syntax:
<input type=“button” name=“name of the
button” value=“buttonlabel”>
<html> 147
<form>
First name :
<input type="button" name="fname"
value="click">
<br>
Last name:
<input type="text" name="lname">
</form>
</html>
148
149
Syntax:
<input type=“submit” name=“name of submit
button” value=“default value”>
<html> 151
<form>
First name :
<input type="submit" name="fname"
value="click">
<br>
Last name:
<input type="text" name="lname">
</form>
</html>
152
153
<html>
<form>
First name :
<input type="reset" name="fname” value=“reset">
<br>
Last name:
<input type="text" name="lname">
</form>
</html>
155
156
157
158
Checkbox:
Syntax:
<html>
<form>
First name :
<input type="checkbox" name="fname"
value="no" >
<br>
Last name:
<input type="text" name="lname">
</form>
</html>
161
<html> 162
<form>
First name :
<input type="checkbox" name="fname"
value="YES" checked >
<br>
Last name:
<input type="text" name="lname">
</form>
</html>
163
164
<html>
<form>
first name:
<input type="button" name="fname" >
</form>
</html>
165
166
<html>
<form>
first name:
<input type=“reset" name="fname" >
</form>
</html>
167
168
<html>
<form>
first name:
<input type="Submit" name="fname" >
</form>
</html>
169
170
SYNTAX :
<Input type = “Radio” Name = “Radiogroup Name”
Value = “Default Value” checked>
172
<html>
<form>
First name :
<input type="radio" name="fname" value="1" >
<br>
Last name:
<input type="text" name="lname">
</form>
</html>
173
174
<html>
<form>
First name :
<input type="radio" name="fname" value="1" >
<input type="radio" name="fname" value="1" >
<input type="radio" name="fname" value="1" >
<br>
Last name:
<input type="text" name="lname">
</form>
</html>
175
176
<html>
<form>
First name :
<input type="radio" name="fname" value="1" >
<input type="radio" name="fname" value="1" >
<input type="radio" name="fname" value="1" checked >
<br>
Last name:
<input type="text" name="lname">
</form>
</html>
177
178
<html>
<form>
</form>
</html>
181
182
<form>
<select name ="atul" size="3" >
<option>french fries1
<option>french fries2
<option>french fries3
<option>french fries4
<option>french fries5
</select>
</form>
</html>
186
187
<html>
<form>
<select name ="atul" size="5" >
<option>french fries1
<option>french fries2
<option>french fries3
<option>french fries4
<option>french fries5
</select>
</form>
</html>
188
189
<html>
<form>
<select name ="atul" size="5" multiple>
<option>french fries1
<option>french fries2
<option>french fries3
<option>french fries4
<option>french fries5
</select>
</form>
</html>
190
191
Comments on HTML:
comments start with <!– and end with -- >
192
<html>
<fieldset>
<legend>
STUDENT
</legend>
<form>
Height <input type="text" size="3">
Weight <input type="text" size="3">
</form>
</fieldset>
</html>
194
195
HTML Input Attributes
Value
Readonly
Disabled
Size
Maxlength
Value
<form action="">
First name:<br>
<input type="text" name="firstname" value="John">
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
Readonly
<form action="">
First name:<br>
<input type="text" name="firstname" value="John"
readonly>
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
Disabled
<form action="">
First name:<br>
<input type="text" name="firstname" value="John"
disabled>
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
Size
<form action="">
First name:<br>
<input type="text" name="firstname" value="John"
size="40">
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
Maxlength
<form action="">
First name:<br>
<input type="text" name="firstname" maxlength="10">
<br>
Last name:<br>
<input type="text" name="lastname">
</form>