Unit2 Ecommerce
Unit2 Ecommerce
Unit2 Ecommerce
HTML stands for Hyper Text Markup Language, which is the most
widely used language on Web to develop web pages.
"HTML 2.0" was the first standard HTML specification which was
published in 1995. HTML 4.01 was a major version of HTML and it was
published in late 1999. Though HTML 4.01 version is widely used but
currently we are having HTML-5 version which is an extension to HTML
4.01, and this version was published in 2012.
HTML Full Form - Each Term Explained
• HTML full form is Hypertext Markup Language. Now, What is a markup
language?, What is Hypertext? Let's explain each term:
• Hypertext: Hypertext means, text with a link embedded in it. If you click on
that link, it will open a new webpage.
<!DOCTYPE html>
<html>
<head>
<title> Page Title </title>
</head>
<body>
<h1> This is a Heading </h1>
<p> This is a Paragraph </p>
</body>
</html>
Explanation of HTML tags used in the Example
• <!DOCTYPE>- The doctype declaration indicates the document type and version of HTML used on the
webpage. Each HTML version has a different doctype declaration. HTML5 Doctype is used in this
example.
• <html>- The HTML tag is the root tag that describes the whole webpage. It is a paired tag, i.e., it has a
closing tag also, </html>. Everything will be written inside these tags.
• <head>- Head tag contains information about the document like its title, author information, description
of the webpage, and so on. It has different tags to perform these functions. It is also a paired tag.
• <title>- Title tag is used inside <head>, and it specifies the title of the document.
• <body>- The body tag contains all the information which will be displayed on the webpage. If you want
anything to be displayed on the webpage, you have to write it within these tags.
• <h1>- Heading tag is used to define headings. <h1> is the largest heading, followed by <h2>, <h3>, to
<h6>
Lets Discuss
1. Do all website use HTML?
2. Is there any alternative for HTML?
3. Is HTML a Programming language?
4. Is HTML hard to understand?
4. What are tags in HTML?
5. What is the meaning of Markup Language?
1. Do all website use HTML?
Yes, all the websites present on the internet use HTML for their
structure. Even different CMS, like wordpress, magento, etc,
where coding knowledge is not necessary, also use HTML to
create websites.
All web pages start with the html element. It’s also
called the root element because it’s at the root of the
tree of elements that make up a web page.
<html>
(all other page elements go here)
</html>
2. <head> … </head> — The document head
<head>
<title>E-Commerce Lab</title>
<link rel="stylesheet" type="text/css" href="/style.css">
</head>
3. <title> … </title> — The page title
<title>
E-Commerce Lab
</title>
4. <body> … </body> — The page’s content
<body>
(all page content goes here)
</body>
5. <h1> … </h1> — A section heading
• The commonly used fonts for web pages are Arial, Comic Sans MS ,
Lucida Sans Unicode, Arial Black, Courier New, Times New Roman,
Arial Narrow, Impact,
Verdana.
• The name is the property you want to set. For example, the
paragraph <p> element in the example carries an attribute whose
name is align, which you can use to indicate the alignment of
paragraph on the page.
• The value is what you want the value of the property to be set and
always put within quotations. The below example shows three
possible values of align attribute: left, center and right.
Example
<html>
<head>
<title>Align Attribute Example</title> </head>
<body>
<p align = "left">This is left aligned</p>
<p align = "center">This is center aligned</p>
<p align = "right">This is right aligned</p>
</body>
</html>
Some <body> Attributes
• Text: The default color for regular text inside the document.
• Bgcolor: A color to fill the background of the document.
• Background: The URL of an image that will be used to cover the
background of the document.
• Example
<body background=“ecom.jpg” text=red >
HTML Elements
Html Elements
• Most HTML elements are written with a start tag (or opening tag) and
an end tag (or closing tag), with content in between. Elements can
also contain attributes that defines its additional properties.
HTML Element Syntax Illustration
HTML Tags Vs Elements
• However, in common usage the terms HTML element and HTML tag
are interchangeable
Case Insensitivity in HTML Tags and Attributes
In HTML, tag and attribute names are not case-sensitive (but most
attribute values are case-sensitive). It means the tag <P>, and the tag
<p> defines the same thing in HTML which is a paragraph.
Empty HTML Elements
<hr>some content</hr> or
<br>some content</br>.
• Most HTML elements can contain any number of further elements (except
empty elements), which are, in turn, made up of tags, attributes, and content
or other elements.
• The following example shows some elements nested inside the <p> element
1. <p>Here is some <b>bold</b> text.</p>
2. <p>Here is some <em>emphasized</em> text.</p>
3. <p>Here is some <mark>highlighted</mark> text.</p>.
Writing Comments in HTML
• Comments are usually added with the purpose of making the source
code easier to understand. It may help other developer (or you in the
future when you edit the source code) to understand what you were
trying to do with the HTML. Comments are not displayed in the
browser.
• An HTML comment begins with <!--, and ends with -->, as shown in
the example below:
<!-- This is an HTML comment -->
<!-- Hiding this image for testing <img
src="images/smiley.png" alt="Smiley"> -->
Physical Text formatting elements
Logical Text formatting elements
Difference between <strong> and <b> tag
Both <strong> and <b> tags render the enclosed text in a bold typeface
by default, but the <strong> tag indicates that its contents have strong
importance, whereas the <b> tag is simply used to draw the reader's
attention without conveying any special importance.
Difference between <em> and <i> tag
Similarly, both <em> and <i> tags render the enclosed text in italic type
by default, but the <em> tag indicates that its contents have stressed
emphasis compared to surrounding text, whereas the <i> tag is used
for marking up text that is set off from the normal text for readability
reasons, such as a technical term, an idiomatic phrase from another
language, a thought, etc.
Character Entities
Example
<HTML>
<HEAD>
<TITLE>Character Entities Example</TITLE>
</HEAD>
<BODY>
<H1 ALIGN="center">Big Company Inc.'s Tagging Products</H1>
<HR>
<P>Character entities like &copy; allow users to insert special characters like
©.</P>
<P>One entity that is both useful and abused is the nonbreaking space.</P>
<BR><BR>
Inserting spaces is easy with &nbsp;<BR>
Look: S P A
C E S.<BR>
<HR>
<ADDRESS>
Contents of this page © 1999 Big Company, Inc.<BR> The
<B>Wonder Tag</B> <P> ™ is a registered trademark
of Big Company, Inc.
</ADDRESS>
</BODY>
</HTML>
Lists
HTML offers three ways for specifying lists of information. All lists
must contain one or more list elements.
• <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 Unordered Lists
• You can use type attribute for <ol> tag to specify the type of
numbering you like. By default, it is a number.
• Following are the possible options
<ol type = "1"> - Default-Case Numerals.
<ol type = "I"> - Upper-Case Numerals.
<ol type = "i"> - Lower-Case Numerals.
<ol type = "A"> - Upper-Case Letters.
<ol type = "a"> - Lower-Case Letters.
Example
<html>
<head> I. Beetroot
<title>HTML Ordered List</title> II.Ginger
</head> III.Potato
<body> IV.Radish
<ol type = "I">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
Examples
i. Beetroot A. Beetroot
ii. Ginger B. Ginger
iii. Potato C. Potato
iv. Radish D. Radish
a) Beetroot
b) Ginger
c) Potato
d) Radish
The start Attribute
• You can use start attribute for <ol> tag to specify the starting
point of numbering you need.
• Following are the possible options
<ol type = "1" start = "4"> - Numerals starts with 4.
<ol type = "I" start = "4"> - Numerals starts with IV.
<ol type = "i" start = "4"> - Numerals starts with iv.
<ol type = "a" start = "4"> - Letters starts with d.
<ol type = "A" start = "4"> - Letters starts with D.
Example
<html>
<head> iv.Beetroot
<title>HTML Ordered List</title> v. Ginger
</head> vi.Potato
<body> vii.Radish
<ol type = "i" start = "4">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
HTML Definition Lists
• HTML and XHTML supports a list style which is
called definition lists where entries are listed like in a
dictionary or encyclopedia. The definition list is the ideal way to
present a glossary, list of terms, or other name/value list.
• Definition List makes use of following three tags.
<dl> − Defines the start of the list
<dt> − A term
<dd> − Term definition
</dl> − Defines the end of the list
Example
html>
<head>
<title>HTML Definition List</title> HTML
</head> This stands for Hyper Text
<body> Markup Language
<dl> HTTP
<dt><b>HTML</b></dt> This stands for Hyper Text
Transfer Protocol
<dd>This stands for Hyper Text Markup
Language</dd>
<dt><b>HTTP</b></dt>
<dd>This stands for Hyper Text Transfer
Protocol</dd>
</dl>
</body>
</html>
HTML - Images
• You can insert any image in your web page by using <img> tag.
Following is the simple syntax to use this tag.
• The <img> tag is an empty tag, which means that, it can contain
only list of attributes and it has no closing tag.
<html>
<head>
<title>Using Image in Webpage</title>
</head>
Example
<body>
<p>Simple Image Insert</p>
<img src = “ecommerce.jpg" alt = "Test Image" />
</body>
</html>
Set Image Width/Height
You can set image width and height based on your requirement
using width and height attributes. You can specify width and
height of the image in terms of either pixels or percentage of its
actual size.
<html>
<head>
<title>Set Image Width and Height</title>
</head>
Example
<body>
<p>Setting image width and height</p>
<img src = “ecommerce.jpg" alt = "Test Image" width = "150" height =
"100"/>
</body>
</html>
Set Image Border
By default, image will have a border around it, you can specify
border thickness in terms of pixels using border attribute. A
thickness of 0 means, no border around the picture.
<html>
<head>
<title>Set Image Border</title>
</head>
Example
<body>
<p>Setting image Border</p>
<img src = “ecommerce.jpg" alt = "Test Image"
border = "3"/>
</body>
</html>
HTML - Tables
• 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
<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>
Table Heading
Table heading can be defined using <th> tag. This tag will be put
to replace <td> tag, which is used to represent actual data cell.
Normally you will put your top row as table heading, otherwise
you can use <th> element in any row. Headings, which are
defined in <th> tag are centered and bold by default.
<html> <head>
<title>HTML Table Header</title>
</head>
<body>
<table border = "1">
<tr>
<th>Name</th>
Example </tr>
<th>Salary</th>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</body>
Cellpadding and Cellspacing Attributes
Example </tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</body> </html>
Colspan and Rowspan Attributes
You will use colspan attribute if you want to merge two or more
Example <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>
Tables Backgrounds
You can set table background using one of the following two
ways −
• bgcolor attribute − You can set background color for whole
table or just for one cell.
• background attribute − You can set background image for
whole table or just for one cell.
• You can also set border color also using bordercolor attribute.
Note − The bgcolor, background, and bordercolor attributes
deprecated in HTML5.
<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>
Example </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>
<html> <head>
<title>HTML Table Background</title>
</head>
<body>
<table border = "1" bordercolor = "green" background = “ecom.jpg">
<tr> <th>Column 1</th>
<th>Column 2</th>
The caption tag will serve as a title or explanation for the table
and it shows up at the top of the table.
Example <tfoot>
<tr>
<td colspan = "4">This is the foot of the table</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
<td>Cell 4</td>
</tr>
</tbody>
</table>
</body>
</body> </html>
Align and Valign
• 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.
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
</head>
<body>
<p>Click following link</p>
<a href = "https://www.dspsr.in" target = "_self">DSPSR</a>
</body>
</html>
HTML Target Attribute
_top Opens the linked document in the full body of the window.
<head>
<title>Hyperlink Example</title>
</head>
<body>
<p>Click following link</p>
<a href = "https://www.dspsr.in" target = "_self">DSPSR</a>
<a href = "https://www.dspsr.in" target = "_parent">DSPSR</a>
<a href = "https://www.dspsr.in" target = "_blank">DSPSR</a>
</body>
</html>
Linking to a Page Section
add an image with a link attached to it. When the user clicks on
<a href="link.html">
<img src="map.png" alt="HTML tutorial" />
</a>
HTML - Marquee Tag
<html>
<head>
<title>HTML marquee Tag</title>
</head>
<body>
<marquee>This is basic example of marquee</marquee>
</body>
</html>
The <marquee> Tag Attributes
Sr.No Attribute & Description
width
This specifies the width of the marquee. This can be a value like 10 or 20% etc.
height This specifies the height of the marquee. This can be a value like 10 or 20% etc.
This specifies the direction in which marquee should scroll. This can be a value like up, down,
direction
left or right.
This specifies the type of scrolling of the marquee. This can have a value like scroll,
behavior
slide and alternate.
scrolldelay This specifies how long to delay between each jump. This will have a value like 10 etc.
scrollamount This specifies the speed of marquee text. This can have a value like 10 etc.
This specifies how many times to loop. The default value is INFINITE, which means that the
loop
marquee loops endlessly.
bgcolor This specifies background color in terms of color name or color hex value.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML marquee Tag</title>
</head>
<body>
<marquee width = "50%">This example will take only 50% width</marquee>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML marquee Tag</title>
</head>
<body>
<marquee direction = "right">This text will scroll from left to right</marquee>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML marquee Tag</title>
</head>
<body>
<marquee direction = "up">This text will scroll from bottom to up</marquee>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title> HTML Scroll Attribute </title>
</head>
<body>
<marquee width="100%" behavior="scroll" direction="up">
This is an example of a scroll marquee Up Side Direction...
</marquee>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title> HTML Scroll Attribute </title>
</head>
<body>
<marquee width="100%" behavior="slide" >
This is an example of slide marquee
</marquee>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title> HTML Scroll Attribute </title>
</head>
<body>
<marquee width="100%" behavior="alternate">
This is an example of a alternate marquee
</marquee>
</body>
</html>
<!DOCTYPE html>
<html >
<head>
<title> HTML Marquee Direction Attribute </title>
</head>
<body>
<marquee width="100%" behavior="scroll" direction="up">
This is an example of a Up side direction marquee...
</marquee>
<marquee width="100%" behavior="scroll" direction="down">
This is an example of a Down side direction marquee...
</marquee>
<marquee width="100%" behavior="scroll" direction="right">
This is an example of a Right side direction marquee...
</marquee>
<marquee width="100%" behavior="scroll" direction="left">
This is an example of a Left side direction marquee...
</marquee>
</body>
</html>
HTML Frames
<head>
<title>HTML Frames</title>
</head>
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
<html>
<head>
<title>HTML Frames</title>
</head>
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
The <frame> Tag Attributes
Attribute Value Description
frameborder 0 It specifies whether to display a border around the frame or
1 not, and its default value is 1
longdsec URL It specifies a page which contains the long description of the
content of the frame.
marginheight pixels It specifies the top and bottom margins of the frame.
• Sometimes you need to add music or video into your web page. The
easiest way to add video or sound to your web site is to include the
special HTML tag called <embed>. This tag causes the browser itself
to include controls for the multimedia automatically provided
browser supports <embed> tag and given media type.
• You can also include a <noembed> tag for the browsers which don't
recognize the <embed> tag. You could, for example, use <embed> to
display a movie of your choice, and <noembed> to display a single
JPG image if browser does not support <embed> tag.
HTML - AUDIO Tag
The HTML <audio> element is used to play an audio file on a web page.
The AUDIO tag of HTML5 supports only three audio file formats i.e.
.ogg, .mp3, .wav
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Attributes: Audio Tag
Attribute Description
Plays the audio file as soon as the
autoplay
Web page loads
Displays the controls on the Web
controls
page, such as play and pause buttons
loop Replays the audio file
Specifies whether the audio file is
preload
preloaded on the Web page or not
Provides the location of the audio file
src
to play
HTML – Video Tag
The HTML <video> element is used to show a video on a web page. The
VIDEO tag supports the .ogv and .mp4 file formats.
autoplay Plays the audio file as soon as the Web page loads
Displays the controls on a Web page, such as play and
controls
pause buttons
height Specifies the height of the VIDEO tag
loop Replays the video file
Specifies whether the video file is preloaded on the
preload
Web page or not
Provides an image to be displayed when the video file is
poster
not available
src Provides the location of the video file to play
width Specifies the width of the VIDEO tag
<!DOCTYPE html>
<html>
<head>
<title>HTML embed Tag</title>
</head>
<body>
<embed src = “abc.mpeg" width = "100%" height = "60" >
<noembed><img src = "yourimage.gif" alt = "Alternative Media" >
</noembed>
</embed>
</body>
</html>
Supported Video Types
You can use various media types like Flash movies (.swf), AVI's (.avi),
and MOV's (.mov) file types inside embed tag.
• .swf files − are the file types created by Macromedia's Flash program.
• .wmv files − are Microsoft's Window's Media Video file types.
• .mov files − are Apple's Quick Time Movie format.
• .mpeg files − are movie files created by the Moving Pictures Expert
Group.
The <embed> Tag Attributes
Sr.No Attribute & Description
1 align
Determines how to align the object. It can be set to either center, left or right.
autostart
2 This boolean attribute indicates if the media should start automatically. You can set it either true or false.
loop
3 Specifies if the sound should be played continuously (set loop to true), a certain number of times (a positive value) or not at all (false)
4 playcount
Specifies the number of times to play the sound. This is alternate option for loop if you are usiong IE.
5 hidden
Specifies if the multimedia object should be shown on the page. A false value means no and true values means yes.
6 width
Width of the object in pixels
7 height
Height of the object in pixels
8 name
A name used to reference the object.
9 src
URL of the object to be embedded.
10 volume
Controls volume of the sound. Can be from 0 (off) to 100 (full volume).
HTML Forms
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.
HTML Form Structure
The HTML <form> tag defines a form that is used to collect user
input. All the form elements should be written inside <form> and
</form> tags.
Syntax:
<form>
....
Form Elements..
....
</form>
Example
HTML Form Controls
• Text Input Controls
• Checkboxes Controls
• Radio Box Controls
• Select Box Controls
• File Select boxes
• Hidden Controls
• Clickable Buttons
• Submit and Reset Button
Text Input Controls
There are three types of text input used on forms −
• Single-line text input controls − This control is used for items that require
only one line of user input, such as search boxes or names. They are
created using HTML <input> tag.
• Password input controls − This is also a single-line text input but it masks
the character as soon as a user enters it. They are also created using HTML
<input> tag.
• Multi-line text input controls − This is used when the user is required to
give details that may be longer than a single sentence. Multi-line input
controls are created using HTML <textarea> tag.
Example:Single-line text input controls
<!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>
Attributes for <input> tag
Sr.No Attribute & Description
type Indicates the type of input control and for text input control it will be set to text.
name Used to give a name to the control which is sent to the server to be recognized and get the
value.
value
This can be used to provide an initial value inside the control.
size
Allows to specify the width of the text-input control in terms of characters.
maxlength
Allows to specify the maximum number of characters a user can enter into the text box.
Example: Password input controls
<!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:Multi-line text input controls
<!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>
Attributes for <textarea> tag
name Used to give a name to the control which is sent to the server to be recognized
and get the value.
rows
Indicates the number of rows of text area box.
cols
Indicates the number of columns of text area box
Checkbox Control
<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>
Attributes for <checkbox> tag
Sr.No Attribute & Description
1
type
Indicates the type of input control and for checkbox input control it
will be set to checkbox..
2 name
Used to give a name to the control which is sent to the server to be
recognized and get the value.
3 value
The value that will be used if the checkbox is selected.
4 checked
Set to checked if you want to select it by default.
Radio Button Control
Radio buttons are used when out of many options, just one option is
required to be selected. They are also created using HTML <input> tag
but type attribute is set to radio.
Example:Radio button controls
<!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>
Attributes for <radio button> tag
Sr.No Attribute & Description
1 type
Indicates the type of input control and for checkbox
input control it will be set to radio.
2 name
Used to give a name to the control which is sent to the
server to be recognized and get the value.
3 value
The value that will be used if the radio box is selected.
4 checked
Set to checked if you want to select it by default.
Select Box Control
A select box, also called drop down box which provides option to list
down various options in the form of drop down list, from where a user
can select one or more options.
Example:Select box controls
<!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>
Attributes for <select> tag
Sr.No Attribute & Description
name Used to give a name to the control which is sent to the server to be recognized and
get the value.
multiple If set to "multiple" then allows a user to select multiple items from the menu.
Attributes for <option> tag
Sr.No Attribute & Description
The value that will be used if an option in the select box box is
value
selected.
label
An alternative way of labeling options
Select Box Control
A select box, also called drop down box which provides option to list
down various options in the form of drop down list, from where a user
can select one or more options.
Example:Select box controls
<!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>
Attributes for <select> tag
Sr.No Attribute & Description
1 name
Used to give a name to the control which is sent to the server to be recognized and get the
value.
2 size
This can be used to present a scrolling list box.
3 multiple
If set to "multiple" then allows a user to select multiple items from the menu.
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.
<BUTTON>Press Me</BUTTON>
Attributes
Sr.No Type & Description
<head>
<title>Buttons</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 =
“unit2.jpg" />
</form>
</body>
</html>
File Upload Box
If you want to allow a user to upload a file to your web site, you will
need to use a file upload box, also known as a file select box. This is
also created using the <input> element but type attribute is set to file.
Example:
<!DOCTYPE html>
<html>
<head>
<title>File Upload Box</title>
</head>
<body>
<form>
<input type = "file" name = "fileupload" accept = "image/*" />
</form>
</body>
</html>
Attributes
Hidden form controls are used to hide data inside the page which later
on can be pushed to the server. This control hides inside the code and
does not appear on the actual page. For example, following hidden
form is being used to keep current page number. When a user will click
next page then the value of hidden control will be sent to the web
server and there it will decide which page will be displayed next based
on the passed current page.
Example:Hidden controls
<!DOCTYPE html>
<html>
<head>
<title> Hidden controls </title>
</head>
<body>
<form>
<p>This is page 10</p>
<input type = "hidden" name = "pagename" value = "10" />
<input type = "submit" name = "submit" value = "Submit" />
<input type = "reset" name = "reset" value = "Reset" />
</form>
</body>
</html>
Grouping Form Data with <fieldset>
The <fieldset> element is used to group related data in a form and the
<legend> element defines a caption for the <fieldset> element.
Example:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title> HTML Form Fieldset and Legend Attributes </title>
</head>
<body>
<form action="action-page.php">
<fieldset>
<legend>Personal information:</legend>
First name:
<input type="text" name="firstname" value="John">
Last name:
<input type="text" name="lastname" value="Snow">
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>
Output
Form Attributes
Sr.No Attribute & Description
action Backend script ready to process your passed data.
method Method to be used to upload data. The most frequently used are GET and POST
methods.
target Specify the target window or frame where the result of the script will be
displayed. It takes values like _blank, _self, _parent etc.
enctype You can use the enctype attribute to specify how the browser encodes the data
before it sends it to the server. Possible values are −
application/x-www-form-urlencoded − This is the standard method most forms
use in simple scenarios.
mutlipart/form-data − This is used when you want to upload binary data in the
form of files like image, word file etc.
The Action Attribute
The action attribute value defines the web page where information
proceed. It can be .php, .jsp, .asp, etc. or any URL where you want to
process your form.
Example:
<!DOCTYPE html>
<html>
<h3>Example of a Submit And Reset Button</h3>
<body>
<form action="test.php" method="post" id="users">
Username:
<input type="text" name="username" id="Username">
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>
The Target Attribute in HTML Forms
The Target attribute is used to specify whether the submitted result will
open in the current window, a new tab or on a new frame. The default
value used is “self” which results in the form submission in the same
window. For making the form result open in a new browser tab, the
value should be set to “blank”.
POST: We can use the post value of method attribute when we want to
process the sensitive data as it does not display the submitted data in URL.
<form action="action.html" method="post">
GET: The get value of method attribute is default value while submitting the
form. But this is not secure as it displays data in URL after submitting the
form.
<form action="action.html" method="get">
Hypertext Transfer Protocol (HTTP)
communication between web browsers and web servers, but it can also
Security Get request is not secured because data is data Post request is secured because data is not
sent is part of the URL, and this data saved in exposed in URL bar and parameters are not
browser history and server logs in plaintext. stored in browser history or in web server logs.
Bookmarked Request can be bookmarked and cached. Request can not be bookmarked and cached.
Usability GET method should not be suitable when you POST is good for when you are sending
are sending sensitive data like user id or sensitive data because your data are sended in
Passwords. encrypted form.
Data Length Data length restricted, usually to 2048 No restrictions on the amount of data that can
characters. be sent.
Hacked Easier to hack. More difficult to hack.
The Autocomplete Attribute
The usemap value starts with a hash tag # followed by the name of the image
map, and is used to create a relationship between the image and the image
map.
2. Create Image Map
Then, add a <map> element.
The <map> element is used to create an image map, and is linked to the image
by using the required name attribute:
<map name="workmap">
The name attribute must have the same value as the <img>'s usemap attribute .
3. The Areas
Then, add the clickable areas.
Shape
You must define the shape of the clickable area, and you can choose one of these values:
You must also define some coordinates to be able to place the clickable area onto the image.
Shape="rect"
The coordinates for shape="rect" come in pairs, one for the x-axis and
one for the y-axis.
So, the coordinates 34,44 is located 34 pixels from the left margin and 44
pixels from the top:
The coordinates 270,350 is located 270 pixels from the left margin and
350 pixels from the top:
<area shape="rect" coords="34, 44, 270, 350" href="computer.htm">
Shape="circle"
To add a circle area, first locate the coordinates of the center of the circle:
337,300
44 pixels
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.html">
<area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.html">
<area shape="circle" coords="337,300,44" alt="Coffee" href="coffee.html">
</map>
</body>
</html>
• Use the HTML <map> element to define an image map
• Use the HTML <area> element to define the clickable areas in the
image map
• Use the HTML usemap attribute of the <img> element to point to
an image map
HTML – Cascading Style Sheet (CSS)
• Cascading Style Sheets (CSS) provide easy and effective alternatives to specify
various attributes for the HTML tags. Using CSS, you can specify a number of
style properties for a given HTML element. Each property has a name and a
value, separated by a colon (:). Each property declaration is separated by a semi-
colon (;).
Example
First let's consider an example of HTML document which makes use of <font> tag
and associated attributes to specify text color and font size
<!DOCTYPE html>
<html>
<head>
<title>HTML CSS</title>
</head>
<body>
<p><font color = "green" size = "5">Hello, World!</font></p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>HTML CSS</title>
Example </head>
<body>
<p style = "color:green; font-size:24px;" >Hello, World!</p>
</body>
</html>
Different ways of using CSS
• External Style Sheet − Define style sheet rules in a separate .css file and then
include that file in your HTML document using HTML <link> tag.
• Internal Style Sheet − Define style sheet rules in header section of the HTML
document using <style> tag.
• Inline Style Sheet − Define style sheet rules directly along-with the HTML
elements using style attribute.
External Style Sheet
If you need to use your style sheet to various pages, then its
always recommended to define a common style sheet in a
separate file. A cascading style sheet file will have extension as
.css and it will be included in HTML files using <link> tag.
Example
Consider we define a style sheet file style.css which has following rules −
.red {
color: red;
}
.thick {
font-size:20px;
}
.green {
color:green;
}
Here we defined three CSS rules which will be applicable to three different classes
defined for the HTML tags
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML External CSS</title>
<link rel = "stylesheet" type = "text/css" href = "/html/style.css">
</head>
<body>
<p class = "red">This is red</p>
<p class = "thick">This is thick</p>
<p class = "green">This is green</p>
<p class = "thick green">This is thick and green</p>
</body> </html>
Internal Style Sheet
font-size:20px;
}
.green {
color:green;
}
</style>
Inline Style Sheet
• You can apply style sheet rules directly to any HTML element using
style attribute of the relevant tag. This should be done only when you
are interested to make a particular change in any HTML element only.
• Rules defined inline with the element overrides the rules defined in
an external CSS file as well as the rules defined in <style> element.