Web Programming-Module 2
Web Programming-Module 2
What you see when you view a page on the Internet is your browser's
interpretation of HTML
Hyper :is the opposite of linear. you can go wherever you want and whenever
you want. For example, it is not necessary to visit MSN.com before you visit
HTML.net.
Text : is self-explanatory.
Mark-up : is what you do with the text. You are marking up the text the same
way you do in a text editing program with headings, bullets and bold text and so
on.
Language: is what HTML is. It uses many English words.
HTML Documents comprised of content and markup tags
The markup tags : tell the Web browser how to display the page
WHERE WE EXECUTE :
1.Double Click that HTML File. (or)
2.Right click – Open With Web browser
HTML Tags
A <TAG> tells the browser to do something.
An ATTRIBUTE goes inside the <TAG> and tells the browser how to do it.
The default value is a value that the browser assumes if you have not
told it .
HTML Tag
</HEAD>
Here the document has been given the title MY WEB PAGE .
Body Tag
The <body> element contains all the contents of an HTML document, such
as text, hyperlinks, images, tables, lists, etc.
<HTML>
<HEAD>
<TITLE> MY WEB PAGE</TITLE>
</HEAD>
<BODY>
This is my first web page.
</BODY>
</HTML>
The BODY tag has following attributes:
LINK: It indicates the colour of the hyperlinks, which have not been
visited or clicked on.
ALINK: It indicates the colour of the active hyperlink. An active link is the
one on which the mouse button is pressed.
VLINK: It indicates the colour of the hyperlinks after the mouse is clicked on it.
TEXT: It is used for specifying the colour of the text displayed on the page.
<HTML>
<TITLE> MY WEBSITE </TITLE>
Welcome to my Website
</BODY>
</HTML>
You also have the option of specifying the colour by giving its name, like:
<HTML>
<BODY BACKGROUND="india.jpeg">
Welcome to INDIA
</BODY>
</HTML>
FORMATTING OF TEXT
Text formatting ie, presenting the text on an HTML page in a desired manner, is
an important part of creating a web page
Headers
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE> MY WEBSITE </TITLE>
</HEAD>
<BODY>
<CENTER>
<H1> Header Level 1</H1>
<H2> Header Level 2</H2>
<H3> Header Level 3</H3>
<H4> Header Level 4</H4>
<H5> Header Level 5</H5>
<H6> Header Level 6</H6>
</CENTER>
</BODY>
</HTML>
The text written between <CENTER> and </CENTER> tag gets aligned in
the center of the HTML page.
The maximum size of the text is displayed using the <H1> tag.
So the size goes in decreasing order with the increasing order of the level
(From <H1> to <H6>).
Formatting Tags
BOLD: The text can be displayed in boldface by writing it in between the <B> and
</B> tags.
ITALICS: It starts with <I> and ends with </I> tag. It is used to display the text in
italics.
UNDERLINE: It is used for underlining the text to be displayed. The <U> tag is
used for this purpose. These tags can be nested. So in order to see the text in
boldface, in italics and underlined, it should be placed between the <B><I><U>
and </U></I></B> tags. Note that the closing tags are written in reverse order,
because any tag used within some other tag should be closed first.
PARAGRAPH: If you want to display the text in the form of paragraphs, then
the <P> tag should be used.
TT: The <TT> tag is used for displaying text in a fixed width font similar to that
of a typewriter.
STRIKE: If you want the text to be marked with a strikethrough character, place
it within the <S> and </S> tags.
STRONG: There are certain text-based browsers that do not render the text as
boldfaced. So you can use the <STRONG> tag instead of the <B> tag. This
displays the text to stand out in the most appropriate manner for the browser.
EM: Just as the <STRONG> tag corresponds to the <B> tag, the <EM> can be
used instead of the <I> tag. The reason for using it is the same as for the
<STRONG> tag. The <EM> tag is used for emphasizing the text in the manner
most appropriate to the browser.
BR: This tag is used for inserting a line break. The text written after the <BR> tag
is displayed from the beginning of the next line onwards. This tag does not need
a corresponding terminating tag.
HR: This tag puts a horizontal line on the page.
It has the following attributes:
• ALIGN: It is used for aligning the line on the page. The possible values of this
attribute are LEFT, RIGHT, and CENTER. It is useful when the width of the line is less
than the width of the page.
• WIDTH: You can set the width of a line using this attribute. The value can be
specified either in pixels or as a percentage of the width of the page, e.g., <HR
WIDTH = “30%”>.
BLOCKQUOTE: This tag indents the left margin of the text. It is used for displaying
the text as quoted text
CITE: The text placed in between the <CITE> and </CITE> tags is rendered in
italics by the browser.
Formatting Tags
<HTML>
<HEAD>
<TITLE> KTU</TITLE>
</HEAD>
<BODY>
<B> KTU </B>
provides several <I> programmes </I>
in the <B><I> Computer </I></B> stream.
<P>
One of the <I> programmes </I> is <B><U> MCA</U></B>
</P>
<B>MCA </B> stands for <TT> Master Of Computer Applications </TT>
<BR>
<S>For MCA</S> <B> KTU </B>
is considered to be one of the best universities.
<BR>
<STRONG>KTU</STRONG> believes in
<STRONG>
<EM>
Quality
</EM>
</STRONG> education
<BR>
<P>
According to <CITE> KTU, </CITE> <B> MCA</B> is one of its best
programmes offering advanced syllabus to the student so that they can
update their knowledge with current affairs.
</P>
<BLOCKQUOTE>
For convenience all the courses offered by KTU can be seen on its website. A
student has also been provided the flexibility of seeing all the information
regarding admission to the next semester, examination result etc. on its website.
</BLOCKQUOTE>
<HR NOSHADE>
<B> KTU contact details are :</B>
<ADDRESS>
KTU, <BR>
KARYAVATTAM, <BR>
TRIVANDRUM – 110 068 <BR>
Website : www.ktu.ac.in
</ADDRESS>
</BODY>
</HTML>
PRE Tag
This tag is used to present the text exactly as written in the code, including
whitespace characters.
The format of the text presented in the browser remains the same as written in the
code.
If we do not use the <PRE> tag, the browser condenses the white space when
presenting the text on the web page.
</PRE>
</BODY>
</HTML>
FONT Tag
HTML provides the flexibility of changing the characteristics of the font such as
size, colour etc.
Every browser has a default font setting that governs the default font name,
size and colour.
Unless you have changed it, the default is Times New Roman 12pt with the
colour being black.
<HTML>
<HEAD>
<TITLE> KTU </TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER>
Welcome to <FONT SIZE=6>INDIA </FONT><BR>
Welcome to <FONT FACE = “ARIAL” SIZE=6>INDIA
</FONT><BR>
Welcome to <FONT FACE = “ARIAL” SIZE=6 COLOUR =
“BLUE”>INDIA </FONT><BR>
</CENTER>
</BODY>
</HTML>
The syntax of the <FONT> tag with its different attributes.
But the font name specified must be present in the system, otherwise the default-
name is used by the browser.
The font will only display if the user has that font installed on the computer.
SIZE: Font can be displayed in any of the 7 sizes:
Tiny
Small
Regular
Extra Medium
Large
Real Big
Largest
COLOUR: With this attribute you can change the desired font colour. The values
can be specified either by using the hexadecimal format as already described, i.e.,
#RGB, or by the name of the colour.
Special Characters
There are certain characters that have special meaning in HTML code.
To display the “< ” character, it can be specified as “<”. The “&” interprets the “lt”
as the “< ” symbol and displays it.
<HTML>
<BODY BGCOLOUR=″#FFFFFF”>
This is
Used for
blank space.
<BR>
< is the Less Than symbol <BR>
> is the Greater Than symbol <BR>
& is the ampersand symbol <BR>
" is the quotation mark symbol <BR>
</BODY>
<HTML>
How to display multiple blank lines.
<HTML>
<HEAD>
<TITLE>IGNOU</TITLE>
</HEAD>
<BODY BGCOLOUR="#FFFFFF">
Welcome to <BR>
<BR>
<BR>
<BR>
INDIA
</BODY>
</HTML>
Check Your Progress 1
Describe yourself on a web page and experiment with colours in BGCOLOUR, TEXT,
LINK, VLINK, and ALINK. Try out different fonts and sizes and also the other tags you
have studied so far, such as the <PRE> tag, as well.
Add the following information to the web page that you created above.
“Job: Software Engineer
The requirement for the job is that the person should be B.E./M.E/M.C.A. having an
aggregate score of 70% or above. The job is project based, so it would be for ½ year
only initially. ¼ of the salary would be deducted towards income tax, PF and other
statutory deductions.”
WORKING WITH IMAGES
WIDTH: This is used for specifying the desired width of the image.
HEIGHT: This is used for specifying the desired height of the image.
BORDER: An important attribute of the IMG tag is BORDER. This attribute specifies
the width of the border of the image. By default it is 0, i.e. there is no border
<BODY BGCOLOR="#FFFFFF">
<IMG SRC="image.gif" WIDTH=130 HEIGHT=101 BORDER=10>
</BODY>
e. ALT: Another IMG attribute that is important is ALT. ALT is sort of a substitute for
the image that is displayed or used when the user is using a browser that does
not display images.
LINKS
A link moves us from the current page to a destination that is specified in the
HTML page.
Anchor Tag
The Anchor tag is used to create links between different objects like HTML
pages,
files, web sites etc. It is introduced by the characters <A> and terminated by
</A>.
HREF is the most common attribute of the ANCHOR tag. It defines the destination
of the link.
<HTML>
<HEAD>
<TITLE>KTU</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
Go to <A HREF="http://www.ktu.edu.in/"> KTU</A>
</BODY>
</HTML>
<BODY BGCOLOR="#FFFFFF">
Send me <A HREF= "mailto:ktu@gmail.com">mail</A>
</BODY>
It is also possible to make an image a link if desired. This is done using the <IMG>
tag. Consider the following example.
<HTML>
<HEAD>
<TITLE>KTU</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
Go to <A HREF="http://ktu.edu.in/"><IMG
SRC="image.gif" WIDTH=130
HEIGHT=101></A>
</BODY>
</HTML
LISTS
Lists are used when the data are to be mentioned in the form of points
Lists break up the monotony of a long paragraph and direct the reader’s attention
to the essential parts.
Lists are segregated into three types, namely Ordered lists, Unordered lists and
Definition lists.
Unordered Lists
These lists are also called bulleted lists. These lists are characterized by list
items that do not have numbers.
They are used when the points in the list have no particular order.
Each point in the list is delimited by the <LI> and </LI> tags.
The syntax of the <UL> tag is:
<LI> </LI>
</UL>
<HTML>
<HEAD>
<TITLE>MY WEBSITE</TITLE>
</HEAD>
<BODY BGCOLOR="#FF0000">
What I wat for my birthday:
<UL Type=“circle”>
<LI>a big red truck</LI>
<LI>an aeroplane that flies</LI>
<LI> a nice soft toy</LI>
<LI>a drum set</LI>
<LI>a Walkman</LI>
<LI> extra pocket money</LI>
</UL>
</BODY>
</HTML>
Ordered Lists
They are used when the items in the list have a natural order.
<OL TYPE=" "> where TYPE= "1", "a", "A", "i", "I"
<LI> </LI>
</OL>
Definition Lists
Definition lists have a heading and the text appears below that.
The Definition heading should be specified between the <DT> and </DT> tags.
The HTML table model allows authors to arrange data -- text, preformatted
text, images, links, forms, form fields, other tables, etc. --
into rows and columns of cells.
An HTML table is defined with the <table> tag.
<TABLE BORDER=5>
<TR>
<TD>Ajay</TD>
</TR>
</TABLE>
<!- - Table with width = 50%- - >
Second: Table with width = 50%
<TABLE BORDER=3>
<TR>
<TD ALIGN=LEFT VALIGN=MIDDLE><IMG SRC="image1.gif"
WIDTH=32 HEIGHT=32></TD>
</TR>
</TABLE>
<!- - A complete Table with different sized columns- - >
CELLPADDING is the amount of space between the border of the cell and the
contents of the cell. The default value for this attribute is 1. This is so that any text
in the cells does not appear to be sticking to the border. However, you can specify a
value of 0 if you wish.
<TABLE BORDER=1>
<TR>
<TD COLSPAN=2>Ajay</TD>
<TD>Vijay</TD>
</TR>
<TR>
<TD>Vikas</TD>
<TD>Pankaj</TD>
<TD>Rohan</TD>
</TR>
</TABLE>
Third: Table with rowspan
<TABLE BORDER=1>
<TR>
<TD ROWSPAN=2>Ajay</TD>
<TD>Vijay</TD>
<TD>Rohan</TD>
</TR>
<TR>
<TD>Pankaj</TD>
<TD>Deepak</TD>
</TR>
</TABLE>
Fourth :Table with rowspan and colspan
<TABLE BORDER=1>
<TR>
<TD ROWSPAN=2>Ajay</TD>
<TD COLSPAN=2>Vijay</TD>
</TR>
<TR>
<TD>Pankaj</TD>
<TD>Rohan</TD>
</TR>
</TABLE>
Fifth: Table with strong tag and a link in cell's data
<TABLE BORDER=1>
<TR>
<TD COLSPAN=3 ALIGN=CENTER><STRONG>
<AHREF="http://KTU.edu.in/">Ajay</STRONG>
</TD>
</TR>
<TR>
<TD>Vijay</TD>
<TD>Vikas</TD>
<TD>Pankaj</TD>
</TR>
</TABLE>
</BODY>
</HTML>
Colspan and Rowspan
If we want the cell c to be extended to the next cell as well and make that area part
of it own, we can use the COLSPAN attribute.
HTML frames are used to divide your browser window into multiple sections where
each section can load a separate HTML document.
The window is divided into frames in a similar way the tables are organized: into
rows and columns.
The <frameset> tag defines, how to divide the window into frames.
The rows attribute of <frameset> tag defines horizontal frames and cols attribute
defines vertical frames.
Each frame is indicated by <frame> tag and it defines which HTML document shall
open into the frame.
<html>
<head>
<title>HTML Frames</title>
</head>
</frameset>
</html>
<html>
<head>
<title>HTML Frames</title>
</head>
</frameset>
</html>
FORMS
The HTML <form> element defines a form that is used to collect user input:
<form>
.
form elements
.
</form>
Form elements are different types of input elements, like text fields,
checkboxes, radio buttons, submit buttons, and more.
The <input> Element
The <input> element can be displayed in several ways, depending on the type
attribute.
Type Description
Example
<form>
First name:<br>
<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname">
</form>
Radio Button Input
Example
<form>
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
</form>
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.
Example
<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>
<input type="submit" value="Submit">
</form>
The Action Attribute
The action attribute defines the action to be performed when the form is
submitted.
Normally, the form data is sent to a web page on the server when the user clicks
on the submit button.
In the example above, the form data is sent to a page on the server called
"/action_page.php". This page contains a server-side script that handles the form
data:
<form action="/action_page.php">
If the action attribute is omitted, the action is set to the current page.
The Method Attribute
The method attribute specifies the HTTP method (GET or POST) to be used
when submitting the form data:
or:
<form action="/action_page.php" method="post">
When to Use GET?
However, when GET is used, the submitted form data will be visible in the page
address field:
/action_page.php?firstname=Mickey&lastname=Mouse
Note: GET must NOT be used when sending sensitive information! GET is best
suited for short, non-sensitive, amounts of data, because it has size limitations
too.
When to Use POST?
Always use POST if the form data contains sensitive or personal information. The
POST method does not display the submitted form data in the page address field.
POST has no size limitations, and can be used to send large amounts of data.
The Name Attribute
If the name attribute is omitted, the data of that input field will not be sent at all.
This example will only submit the "Last name" input field:
Example
<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>
Grouping Form Data with <fieldset>
Example
<form action="/action_page.php">
<fieldset>
<legend>Personal information:</legend>
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</fieldset>
</form>
The <select> Element
Example
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
The <option> elements defines an option that can be selected.
Example
<option value="fiat" selected>Fiat</option>
The <textarea> Element
Example
The rows attribute specifies the visible number of lines in a text area.
Example
Example
<form>
User name:<br>
<input type="text" name="username"><br>
User password:<br>
<input type="password" name="psw">
</form>
Input Type Reset
<input type="reset"> defines a reset button that will reset all form values to their
default values:
Example
<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>
<input type="submit" value="Submit">
<input type="reset">
</form>
Input Type Checkbox
Example
<form>
<input type="checkbox" name="vehicle1" value="Bike"> I have a bike<br>
<input type="checkbox" name="vehicle2" value="Car"> I have a car
</form>
Input Type Color
The <input type="color"> is used for input fields that should contain a color.
Depending on browser support, a color picker can show up in the input field.
Example
<form>
Select your favorite color:<br>
<input type="color" name="favcolor">
</form>
Input Type Date
The <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.
Example
<form>
Birthday:
<input type="date" name="bday">
</form>
Example
<form>
Enter a date before 1980-01-01:
<input type="date" name="someday" max="1979-12-31"><br>
Enter a date after 2000-01-01:
<input type="date" name="someday" min="2000-01-02"><br>
</form>
Input Type Datetime-local
Depending on browser support, a date picker can show up in the input field.
Example
<form>
Birthday (date and time):
<input type="datetime-local" name="bdaytime">
</form>
Input Type Email
The <input type="email"> is used for input fields that should contain an e-mail
address.
Example
<form>
E-mail:
<input type="email" name="email">
</form>
Input Type Month
The <input type="month"> allows the user to select a month and year.
Depending on browser support, a date picker can show up in the input field.
Example
<form>
Birthday (month and year):
<input type="month" name="bdaymonth">
</form>
Input Type Number
Example
<form>
Quantity (between 1 and 5):
<input type="number" name="quantity" min="1" max="5">
</form>
Input Type Range
The <input type="range"> defines a control for entering a number whose exact
value is not important (like a slider control).
Default range is 0 to 100. However, you can set restrictions on what numbers are
accepted with the min, max, and step attributes:
Example
<form>
<input type="range" name="points" min="0" max="10">
</form>
Input Type Tel
The <input type="tel"> is used for input fields that should contain a telephone
number.
Example
<form>
Telephone:
<input type="tel" name="usrtel">
</form>
Input Type Time
The <input type="time"> allows the user to select a time (no time zone).
Example
<form>
Select a time:
<input type="time" name="usr_time">
</form>
Input Type Url
The <input type="url"> is used for input fields that should contain a URL address.
Depending on browser support, the url field can be automatically validated when
submitted.
Example
<form>
Add your homepage:
<input type="url" name="homepage">
</form>
Input Type Week
The <input type="week"> allows the user to select a week and year.
Depending on browser support, a date picker can show up in the input field.
Example
<form>
Select a week:
<input type="week" name="week_year">
</form>
HTML Input Attributes
The value attribute specifies the initial value for an input field:
Example
<form action="">
First name:<br>
<input type="text" name="firstname" value="John">
</form>
The readonly Attribute
The readonly attribute specifies that the input field is read only (cannot be
changed):
Example
<form action="">
First name:<br>
<input type="text" name="firstname" value="John" readonly>
</form>
The disabled Attribute
A disabled input field is unusable and un-clickable, and its value will not be sent
when submitting the form:
Example
<form action="">
First name:<br>
<input type="text" name="firstname" value="John" disabled>
</form>
The size Attribute
The size attribute specifies the size (in characters) for the input field:
Example
<form action="">
First name:<br>
<input type="text" name="firstname" value="John" size="40">
</form>
he maxlength Attribute
With a maxlength
attribute, the input field
will not accept more
than the allowed
number of characters.
The autocomplete attribute specifies whether a form or input field should have autocomplete on or off.
When autocomplete is on, the browser automatically completes the input values based on values that the user has entered
before.
Tip: It is possible to have autocomplete "on" for the form, and "off" for specific input fields, or vice versa.
The autocomplete attribute works with <form> and the following <input> types: text, search, url, tel, email, password,
datepickers, range, and color.
Opera Safari Chrome Firefox Internet Explorer
Example
An HTML form with autocomplete on (and off for one input field):
<form action="/action_page.php" autocomplete="on">
First name:<input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
E-mail: <input type="email" name="email" autocomplete="off"><br>
<input type="submit">
</form>
The novalidate Attribute
When present, novalidate specifies that the form data should not be validated when submitted.
Opera Safari Chrome Firefox Internet Explorer
Example
The form attribute specifies one or more forms an <input> element belongs to.
Tip: To refer to more than one form, use a space-separated list of form ids.
Opera Safari Chrome Firefox Internet Explorer
Example
An input field located outside the HTML form (but still a part of the form):
<form action="/action_page.php" id="form1">
First name: <input type="text" name="fname"><br>
<input type="submit" value="Submit">
</form>
The formaction attribute specifies the URL of a file that will process the input control when the form is submitted.
The formaction attribute overrides the action attribute of the <form> element.
The formenctype attribute specifies how the form data should be encoded when submitted (only for forms with
method="post").
The formenctype attribute overrides the enctype attribute of the <form> element.
Send form-data that is default encoded (the first submit button), and encoded as "multipart/form-data" (the second submit
button):
<form action="/action_page_binary.asp" method="post">
First name: <input type="text" name="fname"><br>
<input type="submit" value="Submit">
<input type="submit" formenctype="multipart/form-data"
value="Submit as Multipart/form-data">
</form>
The formmethod Attribute
The formmethod attribute defines the HTTP method for sending form-data to the action URL.
The formmethod attribute overrides the method attribute of the <form> element.
The second submit button overrides the HTTP method of the form:
<form action="/action_page.php" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
<input type="submit" formmethod="post" formaction="action_page_post.asp"
value="Submit using POST">
</form>
The formnovalidate Attribute
The formnovalidate attribute overrides the novalidate attribute of the <form> element.
The formtarget attribute specifies a name or a keyword that indicates where to display the response that is received after
submitting the form.
The formtarget attribute overrides the target attribute of the <form> element.
The height and width attributes specify the height and width of an <input type="image"> element.
Always specify the size of images. If the browser does not know the size, the page will flicker while images load.
Opera Safari Chrome Firefox Internet Explorer
Example
Define an image as the submit button, with height and width attributes:
<input type="image" src="img_submit.gif" alt="Submit" width="48" height="48">
The list Attribute
The list attribute refers to a <datalist> element that contains pre-defined options for an <input> element.
Opera Safari Chrome Firefox Internet Explorer
Example
<datalist id="browsers">
<option value="Internet Explorer">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
The min and max Attributes
The min and max attributes specify the minimum and maximum values for an <input> element.
The min and max attributes work with the following input types: number, range, date, datetime-local, month, time and week.
Opera Safari Chrome Firefox Internet Explorer
Example
The multiple attribute specifies that the user is allowed to enter more than one value in the <input> element.
The multiple attribute works with the following input types: email, and file.
Opera Safari Chrome Firefox Internet Explorer
Example
The pattern attribute specifies a regular expression that the <input> element's value is checked against.
The pattern attribute works with the following input types: text, search, url, tel, email, and password.
Tip: Use the global title attribute to describe the pattern to help the user.
An input field that can contain only three letters (no numbers or special characters):
Country code: <input type="text" name="country_code" pattern="[A-Za-z]{3}" title="Three letter country code">
The placeholder Attribute
The placeholder attribute specifies a hint that describes the expected value of an input field (a sample value or a short
description of the format).
The hint is displayed in the input field before the user enters a value.
The placeholder attribute works with the following input types: text, search, url, tel, email, and password.
Opera Safari Chrome Firefox Internet Explorer
Example
The required attribute specifies that an input field must be filled out before submitting the form.
The required attribute works with the following input types: text, search, url, tel, email, password, date pickers, number,
checkbox, radio, and file.
Opera Safari Chrome Firefox Internet Explorer
Example
The step attribute specifies the legal number intervals for an <input> element.
Tip: The step attribute can be used together with the max and min attributes to create a range of legal values.
The step attribute works with the following input types: number, range, date, datetime-local, month, time and week.
Opera Safari Chrome Firefox Internet Explorer
Example