Ip 1
Ip 1
Ip 1
UNIT 1: Introduction to HTML - Structure of HTML, HTML elements - Mark up tags for inserting
URL, Images, Tables, Frames - Form and its controls - Image maps - Client and Server Side – CSS
– Inline – Internal and External - Multimedia components - Audio and Video - Dynamic HTML.
In the late 1980's , A physicist, Tim Berners-Lee who was a contractor at CERN, proposed a system
for CERN researchers. In 1989, he wrote a memo proposing an internet based hypertext system.
Tim Berners-Lee is known as father of HTML. The first available description of HTML was a
document called "HTML Tags" proposed by Tim in late 1991.
1) It is a very easy and simple language. It can be easily understood and modified.
2) It is very easy to make effective presentation with HTML because it has a lot of formatting
tags.
3) It is a markup language so it provides a flexible way to design web pages along with the text.
4) It facilitates programmers to add link on the web pages (by html anchor tag) , so it enhances
the interest of browsing of the user.
6) It facilitates the programmer to add Graphics, Videos, and Sound to the web pages which
makes it more attractive and interactive.
➢ HTML stands for Hyper Text Markup Language.
➢ HTML is used to create web pages.
➢ HTML is widely used language on the web.
➢ We can create static website by HTML only.
➢ HTML is an acronym which stands for Hyper Text Markup Language. Let's see what is
Hyper Text and what is Markup Language?
➢ Hyper Text: Hyper Text simply means "Text within Text". A text has a link within it, is
a hypertext. Every time when you click on a word which brings you to a new webpage,
you have clicked on a hypertext.
➢ Markup language: A markup language is a programming language that is used make
text more interactive and dynamic. It can turn a text into images, tables, links etc.
An HTML document is made of many HTML tags and each HTML tag contains different content.
➢ The <!DOCTYPE> declaration represents the document type, and helps browsers to display web pages
correctly.
➢ It must only appear once, at the top of the page (before any HTML tags).
➢ The <!DOCTYPE> declaration is not case sensitive.
Let's see a simple example of HTML.
<!DOCTYPE>
<html>
<body>
<h1>Write Your First Heading</h1>
<p>Write Your First Paragraph.</p>
</body>
</html>
body : Text between body tag describes the body content of the page that is visible to the end
user.
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.
Note: HTML Tags are always written in lowercase letters. The basic HTML tags are given
below:
Formatting is a process of formatting text for better look and feel. There are many formatting
tags in HTML. These tags are used to make text bold, italicized, or underlined. There are almost
15 options available that how text appears in HTML.
1) Bold Text
Output:
2) Italic Text
example:
Output:
Write a First Paragraph in italic text.
3) Marked formatting
If you want to mark or highlight a text, you should write the content within <mark>.........</mark>.
example:
Output:
4) Underlined Text
Output:
Write Your First Paragraph in underlined text.
5) Strike Text
example:
Output:
6) Monospaced Font
If you want that each letter has the same width then you should write the content within
<tt>.............</tt> element.
Note: We know that most of the fonts are known as variable-width fonts because different
letters have different width. (for example: 'w' is wider than 'i'). Monospaced Font provides
similar space among every letter.
Output:
Hello Write Your First Paragraph in monospaced font.
7) Superscript Text
If you put the content within <sup>..............</sup> element, is shown in superscript ; means it is
displayed half a character's height above the other characters.
example:
<p>Hello <sup>Write Your First Paragraph in superscript.</sup></p>
Output:
8) Subscript Text
If you put the content within <sub>..............</sub> element, is shown in subscript ; means it is
displayed half a character's height below the other characters.
example:
Output:
9) Deleted Text
example:
Output:
Hello
example:
Output:
If you want to put your font size larger than the rest of the text then put the content within
<big>.........</big>. It increase one font size larger than the previous one.
example:
Output:
If you want to put your font size smaller than the rest of the text then put the content within
<small>.........</small>tag. It reduces one font size than the previous one.
example:
Output:
Hello Write the paragraph in smaller font.
13) Paragraph
If you want to display the text content in paragraph format then use <p>…….</p> tag.
Example:
<p>This tag is used to display the contents in paragraph format. i.e., the sentences are printed
continuously without any line breaks.</p>
Output:
This tag is used to display the contents in paragraph format. i.e., the sentences are printed
continuously without any line breaks.
If you put a lot of spaces inside the HTML p tag, browser removes extra spaces and extra line
while displaying the page. The browser counts number of spaces and lines as a single one.
14) Ordered & Unordered Lists:
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.
HTML UnorderedLists:
An unordered list is a collection of related items that have no special order or sequence. This list
is created by using HTML <ul> tag. Each item in the list is marked with a bullet.
Example:
<!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></html>
This will produce following result:
</html>
• Beetroot
• Ginger
• Potato
• Radish
Type Attribute:
You can use type attribute for <ul> tag to specify the type of bullet you like. By default it is a disc. Following
are the possible options:
<ul type="square">
<ul type="disc">
<ul type="circle">
Example:
Following is an example where we used <ul type="square">
<!DOCTYPE html>
<html>
<head>
<title>HTML Unordered List</title>
</head>
<body>
<ul type="square">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
▪ Beetroot
▪ Ginger
▪ Potato
▪ Radish
Example:
Following is an example where we used <ul type="disc"> :
<!DOCTYPE html>
<html>
<head>
<title>HTML Unordered List</title>
</head>
<body>
<ul type="disc">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
Example:
Following is an example where we used <ul type="circle">
<!DOCTYPE html>
<html>
<head>
<title>HTML Unordered List</title>
</head>
<body>
<ul type="circle">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
o Beetroot
o Ginger
o Potato
o Radish
HTML OrderedLists:
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>
1. Beetroot
2. Ginger
3. Potato
4. Radish
Example:
Following is an example where we used <ol type="1">
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type="1">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce following result:
1. Beetroot
2. Ginger
3. Potato
4. Radish
Example
Following is an example where we used <ol type="I">
<!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
Example
Following is an example where we used <ol type="i">
<!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
Example
Following is an example where we used <ol type="A">
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type="A">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
A. Beetroot
B. Ginger
C. Potato
D. Radish
Example
Following is an example where we used <ol type="a">
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type="a">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
a. Beetroot
b. Ginger
c. Potato
d. Radish
Example
Following is an example where we used <ol type="i" start="4" >
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type="i" start="4">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
iv. Beetroot
v. Ginger
vi. Potato
vii. Radish
<dt> - A term
HTML
HTTP
The Marquee HTML tag is a non-standard HTML element which is used to scroll a image or
text horizontally or vertically.
In simple words, you can say that it scrolls the image or text up, down, left or right
automatically.
Marquee tag was first introduced in early versions of Microsoft's Internet Explorer. It is
compared with Netscape's blink element.
Example:
Marquee's element contains several attributes that are used to control and adjust the appearance
of the marquee.
Attribute Description
behavior It facilitates user to set the behavior of the marquee to one of the three
different types: scroll, slide and alternate.
direction defines direction for scrolling content. It may be left, right, up and down.
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.
In slide marquee, all the contents to be scrolled will slide the entire length of marquee but stops
at the end to display the content permanently.
It scrolls the text from right to left and goes back left to right.
This is used to change the direction of scrolling text. Let's take an example of marquee scrolling
to the right. The direction can be left, right, up and down.
<marquee width="100%" direction="right">
This is an example of a right direction marquee...
</marquee>
1) Marquee may be distracting because human eyes are attracted towards movement and marquee
text constantly.
2) Since Marquee text moves, so it is more difficult to click static text, depending on the scrolling
speed.
4) It draws user's attention needlessly and makes the text harder to read.
<div> Element
• <div> is used for defining a section of your document. With the div tag, you can group large sections of
HTML elements together and format them with CSS.
• The difference between the div tag and the span tag is that the div tag is used with block-level elements
whilst the span tag is used with inline elements
Example:
<html>
<head> <title>HTML div Tag</title>
</head>
<body>
<div id="contentinfo">
<p>Welcome to our page. We provide HTML notes.</p>
</div>
</body>
</html>
HTML Attributes
Example:
Attribute name
HTML Styling:
Every HTML element has a default style (background color is white, text color is black, text-size
is 12px ...)
Changing the default style of an HTML element, can be done with the style attribute. This
example changes the default background color from white to lightgrey.
Example:
<body style="background-color:lightgrey">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
style="property:value"
The color property defines the text color to be used for an HTML element:
Example:
<!DOCTYPE html>
<html>
<body>
<h1 style="color:blue">This is a heading</h1>
<p style="color:red">This is a paragraph.</p>
</body>
</html>
The font-family property defines the font to be used for an HTML element:
Example:
<!DOCTYPE html>
<html>
<body>
<h1 style="font-family:verdana">This is a heading</h1>
<p style="font-family:courier">This is a paragraph.</p>
</body>
</html>
The font-size property defines the text size to be used for an HTML element:
Example:
<!DOCTYPE html>
<html>
<body>
<h1 style="font-size:300%">This is a heading</h1>
<p style="font-size:160%">This is a paragraph.</p>
</body>
</html>
The text-align property defines the horizontal text alignment for an HTML element:
Example:
<!DOCTYPE html>
<html>
<body>
<h1 style="text-align:center">Centered Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
1.4 Markup Tags for inserting Images, URL, Tables and Frames:
a. Images:
Example:
<img src="Sathyabama.jpg" alt="www.sathyabamauniversity.ac.in" width="104" height
="142">
➢ The source file (src), alternative text (alt), and size (width and height) are attributes.
➢ The alt attribute specifies an alternative text to be used, when an HTML element
cannot be displayed.
b. URL:
The HTML anchor tag defines a hyperlink that links one page to another page i.e., an element
in an electronic document that links to another place in the same document or to an entirely
different document.
The "href" attribute is the most important attribute of the HTML a tag.
The href attribute is used to define the address of the file to be linked. In other words, it points
out the destination page.
➢ The href attribute specifies the destination address (https://www.google.co.in) of the link.
➢ The link text is the visible part (Visit Google India).
➢ Clicking on the link text will send you to the specified address.
Example
This example will open the linked document in a new browser window/tab.
c. Table:
HTML table tag is used to display data in tabular form (row * column). There can be many
columns in a row.
HTML tables are used to manage the layout of the page e.g. header section, navigation bar, body
content, footer section etc. But it is recommended to use div tag over table to manage the layout
of the page.
Tag Description
<col> It is used with <colgroup> element to specify column properties for each column.
Example:
<html>
<body>
<table border="1">
<tr>
<th>Table Header</th>
<th>Table Header</th>
</tr>
<tr>
<td>Table cell 1</td>
<td>Table cell 2</td>
</tr>
<tr>
<td>Table cell 3</td>
<td>Table cell 4</td>
</tr>
</table>
</body>
</html>
Output:
Example
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table border="1">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
</table>
</body>
</html>
Row 3 Cell 1
The three elements for separating the head, body, and foot of a table are:
<html>
<head>
<title>HTML Table</title>
</head>
<body>
<thead>
<tr>
</tr>
</thead>
<tfoot>
<tr>
</tr>
</tfoot>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
<td>Cell 4</td>
</tr>
</tbody>
</table>
</body>
</html>
<Frameset> element and target attribute:
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.
<frameset> tag defines a frameset.
• Each <frameset> holds one or more <frame> elements. Each <frame> element can hold a separate
document.
• <frameset> element specifies HOW MANY columns or rows there will be in the frameset, and HOW
MUCH percentage/pixels of space will occupy each of them.
Example:
frame1.html:
<html>
<body>
<center><h1>This is frame1</h1></center>
</body>
</html>
frame2.html:
<html>
<body>
<center><h1>This is frame2</h1></center>
</body>
</html>
Output:
A simple two-framed (column frames) page:
sampleframe1.html:
<html>
<frameset cols="25%,*">
<frame src="frame1.htm">
<frame src="frame2.htm">
</frameset>
</html>
Output:
Image Mapping:
In Web page development, an image map is a graphic image defined so that a user can click on
different areas of the image and be linked to different destinations. You make an image map by
defining each of the sensitive areas in terms of their x and y coordinates (that is, a certain
horizontal distance and a certain vertical distance from the left-hand corner of the image). With
each set of coordinates, you specify a Uniform Resource Locator or Web address that will be
linked to when the user clicks on that area.
Originally, the map file had to be sent to the server. Now the creator can place the map
information either at the server or at the client (a "client-side map").
clientmap.html:
<html>
<head>
<title>MAPPING</title>
</head>
<body>
<img src="color.jpg" usemap="#shapes">
<map name="shapes">
<area shape="circle" coords=101,114,100 href="circle.html">
<area shape="rect" coords=261,64,343,142 href="rect.html">
<area shape="poly" coords=223,154,171,204,171,256,221,284,271,256,273,204 href="poly.html">
</map>
</bodY>
</html>
Circle.html:
<html>
<head>
<title> circle</title>
</head>
<body>
<h3> This is a circle
</h3>
</body>
</html>
Rectangle.html:
<html>
<head>
<title> rectangle</title>
</head>
<body>
<h3> This is a rectangle</h3>
</body>
</html>
Polygon.html:
<html>
<head>
<title> polygon</title>
</head>
<body>
<h3> This is a polygon</h3>
<a href="image.bmp" target="third">image</a>
</body>
</html>
The X and Y coordinates are expressed in pixels in a different file which has .map extension that
contains the link to the image map.
servermap.asp:
<html>
<head><title>Server-side Image map Example</title></head>
<body>
<h1 align="center">Server-side Image map Test</h1><hr/>
<a href="mapper.map"> <img src="paradise.jpg" ismap alt="Shapes Map"
border="0" width="400" height="200"></a>
</body>
</html>
Mapper.map
default a.jpg
poly b.jpg 16,358,216,378,206,556,66,574,14,358
circle c.jpg 200,200,100
rect Sunset.jpg 250,50,350,150
An external style sheet is ideal when the style is applied to many pages. With an external style
sheet, you can change the look of an entire Web site by changing just one file.
Each page must include a link to the style sheet with the <link> tag. The <link> tag goes inside
the head section:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
An external style sheet can be written in any text editor. The file should not contain any html
tags. The style sheet file must be saved with a .css extension. An example of a style sheet file
called "myStyle.css", is shown below:
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
An internal style sheet should be used when a single document has a unique style. You define
internal styles in the head section of an HTML page, inside the
<style> tag, like this:
Example:
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
An inline style loses many of the advantages of a style sheet (by mixing content with
presentation).
To use inline styles, add the style attribute to the relevant tag. The style attribute can contain
any CSS property. The example shows how to change the color and the left margin of a h1
element:
Example:
HTML Forms:
<Form> </Form>
To let the browser know where to send the content we add these attributes to the <form> tag:
➢ action=address
The address is the url of script the content should be sent to.
➢ method=post or method=get
The post and get methods are simply two different methods for submitting data
to the script
POST offers better security because the submitted data is not visible in the page address.
If the form submission is passive (like a search engine query), and without sensitive information.
When you use GET, the form data will be visible in the page address:
enctype="application/x-www-form-urlencoded"
.
These fields can be added to your forms:
➢ Text field
Text fields are one line areas that allow the user to input text.
The size option defines the width of the field. That is how many visible characters it can contain.
The maxlength option defines the maximum length of the field. That is how many characters can be
entered in the field.
If you do not specify a maxlength, the visitor can easily enter more characters than are visible in
the field at one time.
The name setting adds an internal name to the field so the program that handles the form can
identify the fields.
The value setting defines what will appear in the box as the default value.
➢ Password field
Password fields are similar to text fields. The difference is that what is entered into a
password field shows up as dots on the screen. This is, of course, to prevent others from
reading the password on the screen.
➢ Hidden field
Hidden fields are similar to text fields, with one very important difference!
The difference is that the hidden field does not show on the page
<input type="hidden" name="Language" value="English">
➢ Text area
Text areas are text fields that can span several lines.
Check boxes are used when you want to let the visitor select one or more options
from a set of alternatives. If only one option is to be selected at a time you should use
radio buttons instead.
➢ Radio button
Radio buttons are used when you want to let the visitor select one - and just one - option
from a set of alternatives. If more options are to be allowed at the same time you should
use
check boxes instead.
<input type="radio" name="group1" value="Milk"> Milk<br>
<input type="radio" name="group1" value="Butter" checked>
Butter<br>
<input type="radio Butter<br>
<" name="group1" value="Cheese"> Cheese
➢ Drop-down menu
Drop-down menus are probably the most flexible objects you can add to your forms.
Depending on your settings, drop-down menus can serve the same purpose as radio
buttons (one selection only) or check boxes (multiple selections allowed).
The advantage of a drop-down menu, compared to radio buttons or check boxes, is that it
takes up less space.
But that is also a disadvantage, because people can't see all options in the menu right
away.
➢ Submit button
When a visitor clicks a submit button, the form is sent to the address specified in the action setting
of the <form> tag.
<input type="submit" value="Send me your name!">
➢ Reset button
When a visitor clicks a reset button, the entries are reset to the default values.
<input type="reset" value="Reset!">
➢ Image button
Image buttons have the same effect as submit buttons. When a visitor clicks an image
button the form is sent to the address specified in the action setting of the <form> tag
HTML audio tag is used to define sounds such as music and other audio clips. Currently
there are three supported file format for HTML 5 audio tag.
1. mp3
2. wav
3. ogg
HTML5 supports <video> and <audio> controls. The Flash, Silverlight and similar
technologies are used to play the multimedia items.
This table defines that which web browser supports which audio file format.
Example:
Let's see the code to play mp3 file using HTML audio tag.
<audio controls>
<source src="koyal.mp3" type="audio/mpeg">
Your browser does not support the html audio tag.
</audio>
Example:
Let's see the example to play ogg file using HTML audio tag.
<audio controls>
<source src="koyal.ogg" type="audio/ogg">
Your browser does not support the html audio tag.
</audio>
Attribute Description
controls It defines the audio controls which is displayed with play/pause buttons.
autoplay It specifies that the audio will start playing as soon as it is ready.
loop It specifies that the audio file will start over again, every time when it is completed.
preload It specifies the author view to upload audio file when the page loads.
Here we are going to use controls, autoplay, loop and src attributes of HTML audio tag.
Wav audio/wav
HTML 5 supports <video> tag also. The HTML video tag is used for streaming video files such
as a movie clip, song clip on the web page.
Currently, there are three video formats supported for HTML video tag:
1. mp4
2. webM
3. ogg
Example:
Let's see the code to play mp4 file using HTML video tag.
<video controls>
<source src="movie.mp4" type="video/mp4">
Your browser does not support the html video tag.
</video>
Let's see the example to play ogg file using HTML video tag.
<video controls>
<source src="movie.ogg" type="video/ogg">
Your browser does not support the html video tag.
</video>
controls It defines the video controls which is displayed with play/pause buttons.
poster It specifies the image which is displayed on the screen when the video is not
played.
autoplay It specifies that the video will start playing as soon as it is ready.
loop It specifies that the video file will start over again, every time when it is
completed.
muted It is used to mute the video output.
preload It specifies the author view to upload video file when the page loads.
Example:
Let's see the example of video tag in HTML where are using height, width, autoplay,
controls and loop attributes.
mp4 video/mp4
Ogg video/ogg
webM video/webM
The HTML canvas element provides HTML a bitmapped surface to work with. It is used to
draw graphics on the web page.
The HTML 5 <canvas> tag is used to draw graphics using scripting language like
JavaScript.
The <canvas> element is only a container for graphics, you must need a scripting language to
draw the graphics. The <canvas> element allows for dynamic and scriptable rendering of 2D
shapes and bitmap images.
It is a low level, procedural model that updates a bitmap and does not have a built-in scene.
There are several methods in canvas to draw paths, boxes, circles, text and add images.