Professional Documents
Culture Documents
• The first tag in a pair is the start tag, the second tag is the end tag
(they are also called opening tags and closing tags). In between
these tags web designers can add text, tags, comments and other
types of text-based content.
• When you save an HTML file, you can use either the .htm or the
.html file extension. There is no difference. 1
Tags
HTML markup tags are usually called HTML tags.
The first tag in a pair is the start tag, the second tag is the end tag
Start and end tags are also called opening tags and closing tags
2
Container Tags
• Container tags are those tags that have both opening and closing tags.
• Container tags enclose elements like text, images, and videos.
• The content that we write inside a container tag gets displayed on the
browser.
• The opening and closing tags are also known as On and Off tags.
• For example, the strong tag has both opening and closing tags around the
text: <strong>Hello World</strong>. The content written inside the strong tag,
i.e., "Hello World", will become bold and will be displayed in the browser.
Syntax
<opening_tag> ... </closing_tag>
Empty Tags
• Empty tags are those tags that do not have any closing tags.
• Empty tags only have the opening tag.
• In other words, these tags are self-closing. These tags do not have any text or
embedded elements.
• However, they are used to perform specific actions like inserting line breaks or
adding metadata to the web page.
• For example: <hr> tag, <br> tag
Attributes
• Attributes are used to modify the value of the HTML element.
4
Example
<HTML>
<HEAD>
<TITLE>WEB PAGE DESIGN - INTRODUCTION</TITLE>
</HEAD>
<BODY>
This is my first attempt at a Web page.
</BODY>
</HTML>
5
<HTML> and </HTML> tags
• The first line in the coding reads <HTML>. It
tells the browser that what follows is an HTML
document. It is called the opening HTML tag.
6
<HEAD> and </HEAD> tags
• Each web page must have the HEAD element.
Statements (or tags) that give information to a
person visiting your website, or information
such as those needed for a Search Engine are
placed between the
<HEAD> and </HEAD> tags.
7
<TITLE> and </TITLE> tags
• One of the statements that must be included between the <HEAD>
and </HEAD> tags is the TITLE of your web page. Notice that this
title is placed by the browser at the very top of the screen - above
the menu choices.
• The TITLE of your web page must occur between the <TITLE> and
</TITLE> tags and you are only allowed one TITLE element per
page.
• The information you provide in the title is also used to label the
bookmark entry for your web page. That is, when a visitor
bookmarks your site (adds it to their favorites list), it is the title that
appears in the list.
• Most search engines also use the title in search engine results.
Therefore you should take time to make up a good descriptive title
for each of your web pages.
8
<BODY> and </BODY> tags
• It contains all the text and tags. It is the part
that will be displayed on the browser screen.
Thus the BODY element contains the actual
contents of the document.
• The tags only tell the browser how to display
the information. The body of each of your
Web pages is declared through the BODY
element.
9
Text Formatting Tags
HTML <b> and <strong> Tags
• In HTML, <b> tag and <strong> tag display the text in bold front.
• Example
<b>This text is bold</b>
<strong>This text is important!</strong>
a<sup>2</sup><br>
a<sub>2</sub><br>
<strong>this text is
strong</strong><br>
<em>this text is
emphasised</em><br
>
</body>
11
HTML Headings
• Page headings are created with the <hn> tag, in which n is a
number between 1 and 6.
• Headings are defined with the <h1> to <h6> tags.
• <h1> defines the most important heading. <h6> defines the least
important heading.
• Heading tags make it easy to make global changes to
headings. Eg.
<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>
12
<body>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
</body>
13
HTML Lines(hr tag)
• The <hr> tag creates a horizontal line in an HTML page.
Here, hr stands for horizontal rule.
14
<body>
this is line 1<br>
<hr>
this is line 2<br>
<hr size=20 width=400 color=”green” noshade align=right>
this is line 3<br>
<hr size=30 width=600 color=”blue” noshade align=center>
</body>
15
<br> Tag
• <BR> tells your browser to go to the beginning of the next line. BR
stands for line BReak. <BR> acts in the same way as the ENTER key
on your keyboard.
• With <BR>, the browser is also told to go to the beginning of the
next line.
16
<html>
<body>
first line<br>second line<br>third line
</body>
</html>
17
<P> Tag
<p>This is a paragraph</p>
<p>This is another paragraph</p>
18
•
Example
This tag has one attribute : align with values: left, right,
center.
Example:
<body>
<p align=left>this paragraph is left aligned</p>
<p align=center>this paragraph is center aligned</p>
<p align=right>this paragraph is right aligned</p>
</body>
19
Font Tag
The <font> tag specifies the font face, font size, and font color of
text.
Attribute Description
Size Specifies the font size.
Color Specifies the font color.
Face Specifies the font face.
20
• Example
<p>
<font size=5 face="arial" color=red>
This paragraph is in Arial, size 5, and in red text color.
</font>
</p>
21
<body>
<font face="comic sans MS" size=5 color=red>This is first font
style</font><br><br>
<font face=“arial black" size=7 color=green>This is second font
style</font><br><br>
<font face=“century" size=4 color=blue>This is third font
style</font>
</body>
22
Basefont Tag
• Basefont tag specifies the common font style, size and
color of the text written on the web page.
• It acts as default font for the content i.e. if no font tag is
specified the specifications of basefont will be applicable.
• Bu t where font tag is specified, the specifications of font tag
will overwrite the specification of basefont tag.
• If anyone want some specific line or paragraph of different
font style then font tag can be used for that particular text.
• This tag is specified in <HEAD></HEAD> tag.
23
<head>
<title>abcde</title>
<basefont size=7 color=red face="arial black">
</head>
<body>
<p>
this paragraph will follow the base font
</p>
<p>
<font face="comic sans MS" size=5 color=green>This will
follow the font tag</font><br><br>
</p>
</body>
24
25
Background color and
Background Image
• Background color and background image are attributes of body
tag.
• bgcolor attribute is used to give background color to web page
and background attribute is used to insert any image as the
background of the web page.
• If both bgcolor and background are specified then background
will be visible.
• <html>
<body background="bgimage.jpg" bgcolor="red">
<h1>Hello world!</h1>
</body>
</html>
26
<body bgcolor="pink">
Background color of this page is pink.
</body>
27
<body background="C:\Documents and Settings\All
Users\Documents\My Pictures\Sample Pictures\Water
lilies.jpg">
<font color="red">
<h1 align=center>This page is displaying background
image</h1>
</font>
</body>
28
29
<pre> Preformatting Tag
• Use the <pre> tag for any special circumstances where you
wish to have the text appear exactly as it is typed. Spaces,
tabs, and line breaks that exist in your actual code will be
preserved with the pre tag.
30
<body>
<font face="arial black" color="blue" size=2>
Text with out pre tag: <br><br>
1
2 2
3 3 3
<br><br>
The time has come to
change the world
<br><br>
Produ ct price
Book 250
Shoes 700
Bag 500
</font>
31
<pre>
<font face="arial black" color=red size=2>
Text with pre tag: <br><br>
1
2 2
3 3 3
<br><br>
The time ha s come
to
change
Product pricethe
Book 250 world
<br><br>
Shoes 700
Bag 500
</font>
</pre>
</body> 40
33
Comment Tag
34
<body>
<!--This is a comment. Comments are not displayed in
the
browser-->
35
36
• Inserted Text
Anything that appears within <ins>...</ins>
element is displayed as inserted text.
• Deleted Text
Anything that appears within <del>...</del>
element, is displayed as deleted text.
37
<!DOCTYPE html>
<html>
<head>
<title>Inserted Text
Example</title>
</head>
<body>
<p>I want to drink
<del>coke</del>
<ins>pepsi</ins>
</p>
</body>
</html>
38
• Marked Text
• Anything that appears with-in
<mark>...</mark> element, is displayed as
marked with yellow ink.
39
<html>
<body>
<p><strong>Note:</
strong> The mark tag is
not supported in
Internet Explorer 8 and
earlier versions.</p>
</body>
</html>
40
HTML Lists
41
Introduction
• Lists are used to group related pieces of
information together, so they are clearly
associated with each other and easy to read.
• It is good from structural point of view as they
help create a well-structured, more
accessible, easy-to-maintain document.
• For mentioning a list of items, HTML offers
several mechanisms for specifying lists of
information.
42
Type
s
There are 4 types of Lists:
• Unordered
• Ordered
• Definition
• Directory
43
Unordered Lists
44
• Eg.
<body>
<ul>
<li>Coffee</li>
<li>Cold Drink</li>
</ul>
</body>
Output:
• Coffee
• Cold drink
45
Attributes
:
Type:
• <UL
type=”circle/square/disc”>
Circle
Square
Disc
The
default 46
INPUT OUTPUT
<html>
<body>
<ul type="square">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>
47
Ordered Lists
48
Eg.
<html>
<body>
<ol>
<li>Coffee</li>
<li>Cold drink</li>
</ol>
</body>
</html>
OUTPUT
1. Coffee
2. Cold drink
49
Typ
e
• <OL Type="I"|"A"|"1"|"a"|"i">: designates the
appearance of the numbers preceding the items in the
list, where
"I" causes the items to be numbered I, II, III, IV, V, etc.
"A" causes the items to be numbered A, B, C, D etc.
"1“ causes the items to be numbered 1, 2, 3, 4, 5 etc.
"a" causes the items to be numbered a, b, c, d, e
etc. "i" cause the items to be numbered i, ii, iii, iv, v,
etc.
50
• Start=<value>: this attributes is used whenever
the list is to be started with some specific
value as starting.
• Eg.
<OL type=”1” start=3> : List will start from 3
<OL type=”i” start=3> : List will start from iii
<OL type=”A” start=3> : List will start from C
<OL type=”I” start=3> : List will start from III
<OL type=”a” start=3> : List will start from c
51
FIND OUTPUT
<html> <html>
<body>
<body>
<ol>
<li>Coffee</li> <ol type=“I" start="50">
<li>Tea</li>
<li>Milk</li>
<li>Coffee</li>
</ol> <li>Tea</li>
<li>Milk</li>
<ol start="50">
<li>Coffee</li> </ol>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</body> </html>
</html>
52
Definition Lists
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
</body>
</html>
54
Directory List
• Directory list is similar to UL element. It represents the
elements in bullets. Since there is unordered list for the
purpose, it is depreciated tag and is rarely used.
Eg.
<DIR>
<LI>abc</LI>
<LI>pqr<LI>
<LI>xyz</LI>
</DIR>
Output:
• Abc
• Pqr
• Xyz
55
<!DOCTYPE html>
<html>
<body>
<dir>
<li>html</li>
<li>xhtml</li>
<li>css</li>
</dir>
</body>
</html>
56
TABLES
57
Introduction
• Table can be defined as collection of rows and
columns. All the characteristics applicable to an
entire table are included within the table tag. The
table tag must include a pair <table> and </table>.
There are various other tags:
• <tr>: stands for table row, it is used to
make different rows of the table.
• <th>: stands for table head, it is used to deign
different column names of the table.
• <td>: stands for table data, it is used to enter data
into the table cells.
58
Attribute
s
• background="C:\Documents and Settings\30.jpg": used to
give any background to the table
• bgcolor="pink" : used to set any color for table. For setting
color of particular cell use bgcolor in <td> tag
• border=2 : used to set width of border
• align="left/right/center" : to align the table
• rules="rows/cols/all" : to put lines in rows only, columns only
or both
• width=200 : sets width of table. For setting width of
particular
cells use width in <td> tag.
59
• cellpadding=10 : spacing between cell borders and written
text
• cellspacing=10 : spacing between the cells
• bordercolor="red" : to give color to border
60
<html>
<head>
<title>HTML Tables</title>
</head>
<body>
<table rules= “all“ border=3>
<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>
75
Example
<table>
<tr>
<th>Name</th>
<th>Marks</th>
</tr>
<tr>
<td>A </td>
<td>10</td>
</tr>
<tr>
<td>B</td>
<td>20</td>
</tr>
<tr>
<td>C</td>
<td>30</td>
</tr>
</TABLE>
62
Spanning
• Spanning here means merging. There are
certain cases in which we need to merge rows
or columns.
• It is of two types:
• Rowspan: to merge rows
• Colspan: to merge columns
63
Example
<body>
<table rules="all">
<tr>
<td rowspan=3 align="center">Products and Prices</td>
<td>Book</td>
<td>450</td>
</tr>
<tr>
<td>Diary</td>
<td>80</td>
</tr>
<tr>
<td>Register</td>
<td>50</td>
</tr>
</TABLE>
</body>
64
Output
65
Marquee
• Marquee is one of the important tag
introduced in HTML to support such scrollable
texts and images within a web page.
66
• <html>
• <head>
• <title>Example for HTML Marquee Tag</title>
• </head>
• <marquee>
• This is sample scrolling text.
• </marquee>
• </html>
67
attributes
• Width: provides the width or breadth of a
marquee.
• For example width="10”
• Height provides the height or length of a
marquee. For example height="20"
• Direction provides the direction or way in
which your marquee will allow you to scroll.
The value of this attribute can be: left,
right, up or down
• Bgcolor provides a background color where
the value will be either the name of the color
or the hexadecimal color-code. 87
• loop
• This specifies how many times to loop. The
default value is INFINITE, which means that the
marquee loops endlessly.
SCROLLDELAY, together with SCROLLAMOUNT, sets
the speed of the scrolling.
• Scroll
• Slide
• Alternate
70
• <html>
• <head>
• <title>Example for HTML Marquee Tag</title>
• </head>
• </html>
71
72
• Add Other Characters- Here are a few other common escape
codes:
• " -> " for double quotation marks
• ' -> ‘ for single quotation marks
• © -> © for the copyright symbol
• ® -> ® for the registered trademark symbol
• ¢ -> ¢ for the cent sign
• £ -> £ for the pound sign
• ¥ -> ¥ for the yen sign
• € -> € for the euro sign
• ← -> ← for the leftwards arrow
• ↑ -> ↑ for the upwards arrow
• → -> → for the rightwards arrow
• ↓ -> ↓ for the downwards arrow
• ° -> ° for the degree sign
• ¶ -> ¶ for the paragraph symbol
• ÷ -> ÷ for the division symbol
• ∴ -> ∴ for the therefore symbol
73
HTML Forms
74
• The <form> Element
• The HTML <form> element defines a form that is
used to collect user input:
• <form>
.
form elements
.
</form>
name="firstname">
<br>
Last name:<br>
<input type="text"
name="lastname">
</form> 77
Radio Button Input
<input type="radio"> defines a radio button.
Radio buttons let a user select ONE of a limited number
of choices:
• <form>
<input type="radio" name
="gender" value="male“ ch
ecked> Male<br>
<input type="radio" name
="gender" value="female">
Female<br>
<input type="radio" name
="gender" value="other"> O
ther
</form>
78
<html>
<body>
<form
action="/action_page.php”>
<input type="checkbox"
name="vehicle" value="Bike">
I have a bike<br>
<input type="checkbox"
name="vehicle" value="Car"
checked> I have a car<br>
<input type="submit"
value="Submit">
</form>
</body>
</html>
79
The Submit Button
<input type="submit"> defines a button for submitting the form
data to a form-handler.
The form-handler is typically a server page with a script for
processing input data.
The form-handler is specified in the form's action attribute:
<form action="/action_page.php">
First name:
<br>
<input type="text"
name="firstname"
value="Mickey">
<br>
Last name:
<br>
<input type="text"
name="lastname"
value="Mouse">
<br><br>
101
<input type="submit" value="Sub
The Action Attribute
83
84
The Name Attribute
85
• <form action="/action_page.php">
First name:<br>
<input type="text" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="
Mouse"><br><br>
<input type="submit" value="Submit">
</form>
86
Select Boxes
87
88
• Create a drop down list for 2 values :
• Maths
• physics
89
<html>
<head>
<title>Select Box Control</title>
</head>
<body>
<form>
<select name = "dropdown">
<option value = "Maths" >Maths</option>
<option value = "Physics"selected>Physics</option>
</select>
</form>
</body>
</html>
90
Button
91
92
93
input type="date">
• is used for input fields that should
contain a date.
• Depending on browser support, a date picker
can show up in the input field.
94
• <form action="/action_page.php">
• Birthday:
• <input type="date" name="bday">
• <input type="submit">
• </form>
95
96
Input Type Email
• <form>
E-mail:
<input type="email" name="email">
</form>
97
98
Input Type Number
• The <input type="number"> defines
a numeric input field.
• You can also set restrictions on what numbers are
accepted.
• The following example displays a numeric input
field, where you can enter a value from 1 to 5:
• <form>
Quantity (between 1 and 5):
<input type="number" name="quantity" min="1
" max="5">
</form>
99
100
101
102
103
Textarea: container tag
<html>
<head>
<title>Form Example</title>
</head>
<body>
</form>
</body>
</html>
104
Button Controls
• There are various ways in HTML to create clickable
buttons. You can also create a clickable button using
<input>tag by setting its type attribute to button.
The
type attribute can take the following values −
• Submit: This creates a button that automatically
submits a form.
• Reset: This creates a button that automatically resets
form controls to their initial values.
• Button: This creates a button that is used to trigger a
client-side script when the user clicks that button.
• image : This creates a clickable button but we can use
an image as background of the button. 134
<html>
<head>
<title>types of Button </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>
135
107
There are 3 ways of implementing
style in HTML :
• Inline Style : In this method, the style
attribute is used inside the HTML body tag.
• Embedded Style : In this method, the style
element is used inside the <head> element of
the document.
• External Style Sheet : In this method the
<link> element is used to point to an external
CSS file.
Inline Style
• In Inline styling, the rules are directly written
inside the starting tag using the style attribute
• . The style attribute includes property and
value pairs.
• Each ‘ property : value ‘ pair is separated by a
semicolon ( ; ).
<!DOCTYPE html>
<html>
<body>
<h1 style="color:Blue;font-size:25px;">
Example of Inline Style</h1>
<p style="color:red;">First
paragraph</p>
<p style="color:green;font-size:40px;">
Second paragraph</p>
<hr style="border-color:orange;">
</body>
Embedded Style :
<h1>This is a
heading</h1>
<p>This is a
paragraph.</p
>
<h1> this is another
heading<h1>
<!DOCTYPE html>
<html>
<head>
<style>
body {background-color:
powderblue;}
h1 {color: blue;}
p {color: red;}
</style>
</head>
<body>
<h1>This is a
heading</h1>
<p>This is a
paragraph.</p>
</body>
<!DOCTYPE html>
<html>
<body>
<h1 style="color:blue;text-
align:center">This is a
header</h1>
<p
style="color:green">Thi s
is a paragraph.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>HTML CSS</title>
font size=24
</head>
<body>
<p style = "color:green; font-size:24px;" >
Hello, World!</p>
</body>
</html>
• <!DOCTYPE html>
• <html>
•
• <head>
• <title>HTML Inline CSS</title>
• </head>
•
• <body>
• <p style = "color:red;">This is red</p>
• <p style = "font-size:20px;">This is thick</p>
• <p style = "color:green;">This is green</p>
• <p style = "color:green;font-size:20px;">This is
thick and green</p>
• </body>
•
• </html>
Difference between cellspacing and cellpadding:
• Both are related to cells height and width in cellpadding space between 1 cell and
cellspacing means space between 2 cells.
• Think of a cell as a box. Cellspacing is the space between boxes. Cellpadding is the
space between the content inside the box and its borders.
• CellSpacing is used to set space between different table cells. CellPadding is used
the space between the edges of the cell and the content of the cell.
• Cellpadding space between Content of cell and Cell Wall while Cellspacing is space
between two cells .
Exercise
• Create an html table with caption as shown below:
<html>
<html>
<body style="background-color:red;">
<body style="background-color: orange;">
<h2>Frame 1</h2>
<h2>Frame 2</h2>
</body>
</body>
</html>
</html>
Frame1.html Frame2.html
OUTPUT
• Now if you want to divide your page column wise, use cols attribute. The code can
be:
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset cols = "30%,70%">
<frame src = "frame1.html" />
<frame src = "frame2.html" />
</frameset>
</html>
<noframes> tag
• If a user is using any old browser or any browser, which does not support frames
then <noframes> element should be displayed to the user.
• So you must place a <body> element inside the <noframes> element because
the
<frameset> element is supposed to replace the <body> element, but if a browser
does not understand <frameset> element then it should understand what is inside
the <body> element which is contained in a <noframes> element.
• You can put some nice message for your user having old browsers. For
example, Sorry!! your browser does not support frames. as shown in the below
example.
<html>
<frameset cols = "25%,50%,25%">
<frame src = “top_frame.htm" />
<frame src = “main_frame.htm" />
<frame src = bottom_frame.htm" />
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
Frame's name and target attributes
• One of the most popular uses of frames is to place navigation bars in one frame
and then load main pages into a separate frame.
• Let's see following example where a test.html file has following code −
<html>
<head> <title>HTML Target Frames</title>
</head>
<frameset cols = "200, *">
<frame src = “menu.html" name = "menu_page" />
<frame src = “main.html" name = "main_page" />
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
• Here, we have created two columns to fill with two frames. The first frame is 200
pixels wide and will contain the navigation menu bar implemented
by menu.html file.
• The second column fills in remaining space and will contain the main part of the
page and it is implemented by main.html file. For all the three links available in
menu bar, we have mentioned target frame as main_page, so whenever you click
any of the links in menu bar, available link will open in main page.
• Following is the content of menu.html file:
<html>
<body bgcolor = "#4a7d49">
<a href="ecommerce.html" target= "main_page">E-commerce</a>
<br /> <br />
<a href="costaccounting.html" target ="main_page">Cost Accounting</a>
<br /> <br />
<a href="businessEnvironment.html" target = "main_page">Business Environment</a>
</body>
</html>
• Following is the content of main.html file −
<html>
<<body bgcolor = "#b5dcb3">
<h3>This is main page and content from any link will be displayed here.</h3> <p>So
now click any link and see the result.</p>
</body>
</html>
• When we load test.html file, it produces following result −
• Now you can try to click links available in the left panel and see the result.
• <frameset rows="*,*" cols="*,*"> <frame
src="frame_1.html"> <frame
src="frame_2.html"> <frame
src="frame_3.html"> <frame
src="frame_4.html"> </frameset>
•
<html>
<frameset cols="*,*,*,*">
<frame src=“frame_1.html">
<frame src="frame_2.html">
<frame src="frame_3.html">
<frame src="frame_4.html">
</frameset>
</html>
<html>
<frameset rows="*,*,*,*">
<frame src="frame_1.html">
<frame src="frame_2.html">
<frame src="frame_3.html">
<frame src="frame_4.html">
</frameset>
</html>
Mixing Columns and Rows
• Columns and rows of frames can both appear on the same webpage by nesting
one frameset inside of another.
• To do this, we first create a frameset and then nest a child frameset within the
parent element. Here’s an example of how we could nest two rows within a set of
three columns.
<frameset cols="*,*,*">
<frameset rows="*,*">
<frame src="frame_1.html">
<frame src="frame_2.html">
</frameset>
<frame src="frame_3.html">
<frame src="frame_4.html">
</frameset>
• Another example-
<frameset cols="*,*,*">
<frame src="frame_1.html">
<frameset rows="*,*">
<frame src="frame_2.html">
<frame src="frame_3.html">
</frameset>
<frame src="frame_4.html">
</frameset>