HTML Input Types
HTML Input Types
<html>
<head>
</head>
<body>
<img src="images\img_nat.png" width="120" height="80" alt="Natural" align="right"/>
<p>Natural resources (economically referred to as land or raw materials)
occur naturally within environments that exist relatively undisturbed by mankind, in a natural form. A natural
resource is often characterized by amounts of biodiversity existent in various ecosystems.</p>
</body>
</html>
Image alignment (Wrap around)
<html>
<head>
</head>
<body>
<img src="images\img_nat.png" width="120" height="80" alt="Natural" align="left"/>
<p>Natural resources (economically referred to as land or raw materials)
occur naturally within environments that exist relatively undisturbed by mankind, in a natural form. A natural
resource is often characterized by amounts of biodiversity existent in various ecosystems. Natural
<br clear="all" />
resources are derived from the environment. Many of
them are essential for our survival while others are used for satisfying
our wants. Natural resources may be further classified in different ways.
</p>
</body> </html>
Image Link
<html>
<head>
</head>
<body>
<a href="http://www.way2tutorial.com/html/tutorial.php">
<img src="images\img_nat.png" width="120" height="70" alt="Natural" />
</a>
</body>
</html>
• HTML Internal Link is linked within the same web page. This link can be absolute path or relative path.
• HTML internal link name is followed by head sign(#). HTML <a> tag is use for anchor point name,
which is referred to a internal link into a same page.
• When click on this anchor link, It's referred link automatically scrolls and display on browser.
• Example: <a name="Lession.1"> link can be referred as <a href="#Lession.1">Lession.1</a>
automatically.
Example
<html>
<head>
</head>
<body>
<a href="#Lession.1">Lession.1</a> <br />
<a href="#Lession.2">Lession.2</a> <br />
<a href="#Lession.3">Lession.3</a> <br />
<a href="#Lession.4">Lession.4</a> <br />
<br />
<a name="Lession.1">Introduction of Lession.1</a>
<p>This is sub topic.1</p>
<p>This is sub topic.2</p>
<p>This is sub topic.3</p>
<p>This is sub topic.4</p>
<br />
<br />
<a name="Lession.2">Introduction of Lession.2</a>
<p>This is sub topic.1</p>
<p>This is sub topic.2</p>
<p>This is sub topic.3</p>
<p>This is sub topic.4</p>
<br />
<br />
<a name="Lession.3">Introduction of Lession.3</a>
<p>This is sub topic.1</p>
<p>This is sub topic.2</p>
<p>This is sub topic.3</p>
<p>This is sub topic.4</p>
<br />
<br />
<a name="Lession.4">Introduction of Lession.4</a>
<p>This is sub topic.1</p>
<p>This is sub topic.2</p>
<p>This is sub topic.3</p>
<p>This is sub topic.4</p>
</body>
</html>
• HTML Link - External HTML Links is linked to external web page. This link is may be absolute path or
relative link path.
• <a> tag is used for anchor name which is referred link to another web page.
• External link is great future to drive a webpage one to another and useful for surf many webpage in
website.
Example
<html>
<head>
</head>
<body>
<a href="html.php">HTML</a>
<br />
<br />
<a href="css.php">CSS</a>
<br />
<br />
<a href="javascript.php">Java Script</a>
<br />
</body>
</html>
Definition
• HTML <marquee> tag use to create a scrolling text or scrolling image from left to right, right to left, top
to bottom, bottom to top. There is no limit. It's user define choice.
• <marquee> tag is a container tag to create scrolling text.
• <marquee> tag support following some attributes. This attributes use to add more special effect and easy
control.
• HTML <marquee> tag use to create a scrolling text from left to right, right to left, top to bottom, bottom
to top. There is no limit. HTML Marquee tag is use to display text in marquee style.
• <marquee> tag is a container tag.
<html>
<head>
</head>
<body>
<marquee behavior="scroll" direction="left">Continuous scrolling text</marquee>
</body>
</html>
<html>
<head>
</head>
<body>
<marquee behavior="alternate" direction="left">Side Touch Margin Bounce Text</marquee>
</body>
</html>
Upside Text Scrolling
<html>
<head>
</head>
<body>
<marquee behavior="scroll" direction="up">Upside Text Scrolling</marquee>
</body>
</html>
<html>
<head>
</head>
<body>
<marquee behavior="scroll" direction="left" scrollamount="3">Slow speed scroll speed</marquee>
<marquee behavior="scroll" direction="left" scrollamount="10">Medium speed scroll speed</marquee>
<marquee behavior="scroll" direction="left" scrollamount="17">Fast speed scroll speed</marquee>
</body>
</html>
• HTML <marquee> tag is a container tag and use to create a scrolling image from left to right, right to
left, top to bottom, bottom to top. There is no limit and image display in marquee style.
<html>
<head>
</head>
<body>
<marquee behavior="scroll" direction="left">
<img src="../images/img_nat.png" width="120" height="80" alt="Natural" />
</marquee>
</body>
</html>
<html>
<head>
</head>
<body>
<marquee behavior="slide" direction="left">
<img src="../images/img_nat.png" width="120" height="80" alt="Natural" />
</marquee>
</body>
</html>
Side Touch Margin Bounce Image
<html>
<head>
</head>
<body>
<marquee behavior="alternate" direction="left">
<img src="../images/img_nat.png" width="120" height="80" alt="Natural" />
</marquee>
</body>
</html>
<html>
<head>
</head>
<body>
<marquee behavior="scroll" direction="up">
<img src="../images/img_nat.png" width="120" height="80" alt="Natural" />
</marquee>
</body>
</html>
<html><head>
</head>
<body>
<marquee behavior="scroll" direction="left" scrollamount="5">
<img src="../images/img_nat.png" width="120" height="80" alt="Natural" />
</marquee>
<marquee behavior="scroll" direction="left" scrollamount="15">
<img src="../images/img_nat.png" width="120" height="80" alt="Natural" />
</marquee>
</body>
</html>
• HTML <marquee> tag use to create a scrolling text as well as you assign click, hover and button effect
to control start/stop marquee text/image. Lets see following some example.
<html><head>
</head>
<body>
<marquee behavior="scroll" direction="left"
onmousedown="this.stop();"
onmouseup="this.start();">Click and hold the mouse marquee stop</marquee>
</body></html>
Hover to Stop Marquee
<html>
<head>
</head>
<body>
<marquee behavior="scroll" direction="left"
onmouseover="this.stop();"
onmouseout="this.start();">Hower over and hold the mouse marquee stop</marquee>
</body>
</html>
<html>
<head>
</head>
<body>
<marquee behavior="scroll" direction="left" id="marquee1"><p>Press Button</p></marquee>
<input type="button" value="Stop Marquee" onClick="document.getElementById('marquee1').stop();"/>
<input type="button" value="Start Marquee" onClick="document.getElementById('marquee1').start();"/>
</body>
</html>
<html>
<head>
</head>
<body>
<marquee behavior="scroll" direction="left" scrollamount="10" id="marquee2"><p>Marquee
1</p></marquee>
<marquee behavior="scroll" direction="left" scrollamount="15" id="marquee3"><p>Marquee
2</p></marquee>
<input type="button" value="Stop Marquee 1" onClick="document.getElementById('marquee2').stop();"/>
<input type="button" value="Start Marquee 1" onClick="document.getElementById('marquee2').start();"/><br
/>
<input type="button" value="Stop Marquee 2" onClick="document.getElementById('marquee3').stop();"/>
<input type="button" value="Start Marquee 2" onClick="document.getElementById('marquee3').start();"/>
</body>
</html>
HTML Marquee Text Speed Slow/Fast Examples
• HTML <marquee> tag use to create a scrolling text as well as you also allow to Click or Hover effect to
control the speed of marquee text or image.
<html>
<head>
</head>
<body>
<marquee behavior="scroll" direction="left"
onmousedown="this.setAttribute('scrollamount', 3, 0);"
onmouseup="this.setAttribute('scrollamount', 10, 0);">Click and hold the mouse marquee speed
slow</marquee>
</body>
</html>
<html>
<head>
</head>
<body>
<marquee behavior="scroll" direction="left"
onmouseover="this.setAttribute('scrollamount', 3, 0);"
onmouseout="this.setAttribute('scrollamount', 10, 0);">Hover over to slow Marquee Speed</marquee>
</body>
</html>
<html>
<head>
</head>
<body>
<marquee behavior="scroll" direction="left" scrollamount="6" id="marquee5">Marquee slow/medium/fast
speed using buttons</marquee>
<input type="button" value="Slower"
onClick="document.getElementById('marquee5').setAttribute('scrollamount', 1, 0);" />
<input type="button" value="Medium"
onClick="document.getElementById('marquee5').setAttribute('scrollamount', 5, 0);" />
<input type="button" value="Faster"
onClick="document.getElementById('marquee5').setAttribute('scrollamount', 10, 0);" />
</body>
</html>
HTML Marquee Falling Text
• HTML <marquee> falling text style is a combination of one or multiple falling text are drop down from
upside to lowerside.
<html>
<head>
</head>
<body>
<marquee style="z-index:2;position:absolute;left:18px;top:97px;font-family:Cursive;font-
size:14pt;color:#ffcc00;height:200px;" scrollamount="3" direction="down">Way2Tutorial.com</marquee>
<marquee style="z-index:2;position:absolute;left:1px;top:89px;font-family:Cursive;font-
size:14pt;color:#ffcc00;height:100px;" scrollamount="7" direction="down">Way2Tutorial.com</marquee>
<marquee style="z-index:2;position:absolute;left:111px;top:7px;font-family:Cursive;font-
size:14pt;color:#ffcc00;height:302px;" scrollamount="4" direction="down">Way2Tutorial.com</marquee>
<marquee style="z-index:2;position:absolute;left:225px;top:83px;font-family:Cursive;font-
size:14pt;color:#ffcc00;height:371px;" scrollamount="3" direction="down">Way2Tutorial.com</marquee>
</body>
</html>
HTML FORMS
4. The <form> Element
The HTML <form> element defines a form that is used to collect user input:
<form>
.
form elements
.
</form>
An HTML form contains form elements.
Form elements are different types of input elements, like text fields, checkboxes, radio buttons, submit buttons,
and more.
Text Input
<input type="text"> defines a one-line input field for text input:
Example
<form>
First name:<br>
<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname">
</form>
This is how it will look like in a browser:
First name:
Last name:
Last name:
Mouse
Last name:
User password:
Last name:
Mouse
If you omit the submit button's value attribute, the button will get a default text:
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">
</form>
Last name:
Mouse
If you change the input values and then click the "Reset" button, the form-data will be reset to the default
values.
Input Type Radio
<input type="radio"> defines a radio button.
Radio buttons let a user select ONLY ONE of a limited number of choices:
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>
This is how the HTML code above will be displayed in a browser:
Male
Female
Other
Input Restrictions
Here is a list of some common input restrictions (some are new in HTML5):
Attribute Description
disabled Specifies that an input field should be disabled
max Specifies the maximum value for an input field
maxlength Specifies the maximum number of character for an input field
min Specifies the minimum value for an input field
pattern Specifies a regular expression to check the input value against
readonly Specifies that an input field is read only (cannot be changed)
required Specifies that an input field is required (must be filled out)
size Specifies the width (in characters) of an input field
step Specifies the legal number intervals for an input field
value Specifies the default value for an input field
The following example displays a numeric input field, where you can enter a value from 0 to 100, in steps of 10.
The default value is 30:
Example
<form>
Quantity:
<input type="number" name="points" min="0" max="100" step="10" value="30">
</form>
HTML5 Attributes
HTML5 added the following attributes for <input>:
• autocomplete
• autofocus
• form
• formaction
• formenctype
• formmethod
• formnovalidate
• formtarget
• height and width
• list
• min and max
• multiple
• pattern (regexp)
• placeholder
• required
• step
and the following attributes for <form>:
• autocomplete
• novalidate
You can also define the size of the text area by using CSS:
Example
<textarea name="message" style="width:200px; height:600px">
The cat was playing in the garden.
</textarea>
Note: Always specify the type attribute for the button element. Different browsers may use different default
types for the button element.
8. HTML GRAPHICS
HTML5 Canvas
Browser Support
The numbers in the table specify the first browser version that fully supports the <canvas> element.
Element
<canvas> 4.0 9.0 2.0 3.1 9.0
Canvas Examples
A canvas is a rectangular area on an HTML page. By default, a canvas has no border and no content.
The markup looks like this:
<canvas id="myCanvas" width="200" height="100"></canvas>
Note: Always specify an id attribute (to be referred to in a script), and a width and height attribute to define the
size of the canvas. To add a border, use the style attribute.
Here is an example of a basic, empty canvas:
Example
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">
</canvas>
Draw a Line
Example
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.moveTo(0, 0);
ctx.lineTo(200, 100);
ctx.stroke();
Draw a Circle
Example
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(95, 50, 40, 0, 2 * Math.PI);
ctx.stroke();
Draw a Text
Example
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.font = "30px Arial";
ctx.fillText("Hello World", 10, 50);
Stroke Text
Example
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.font = "30px Arial";
ctx.strokeText("Hello World", 10, 50);
// Create gradient
var grd = ctx.createLinearGradient(0, 0, 200, 0);
grd.addColorStop(0, "red");
grd.addColorStop(1, "white");
// Create gradient
var grd = ctx.createRadialGradient(75, 50, 5, 90, 60, 100);
grd.addColorStop(0, "red");
grd.addColorStop(1, "white");
Draw Image
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("scream");
ctx.drawImage(img, 10, 10);
HTML5 SVG
What is SVG?
• SVG stands for Scalable Vector Graphics
• SVG is used to define graphics for the Web
• SVG is a W3C recommendation
Browser Support
The numbers in the table specify the first browser version that fully supports the <svg> element.
Element
<svg> 4.0 9.0 3.0 3.2 10.1
SVG Circle
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
SVG Rectangle
Example
<svg width="400" height="100">
<rect width="400" height="100" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
SVG Star
Sorry, your browser does not support inline SVG.
Example
<svg width="300" height="200">
<polygon points="100,10 40,198 190,78 10,78 160,198"
style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;" />
</svg>
SVG Logo
SVG Sorry, your browser does not support inline SVG.
Example
<svg height="130" width="500">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" />
</linearGradient>
</defs>
<ellipse cx="100" cy="70" rx="85" ry="55" fill="url(#grad1)" />
<text fill="#ffffff" font-size="45" font-family="Verdana" x="50" y="86">SVG</text>
Sorry, your browser does not support inline SVG.
</svg>
What is Multimedia?
Multimedia comes in many different formats. It can be almost anything you can hear or see.
Examples: Images, music, sound, videos, records, films, animations, and more.
Web pages often contain multimedia elements of different types and formats.
In this chapter you will learn about the different multimedia formats.
Browser Support
The first web browsers had support for text only, limited to a single font in a single color.
Later came browsers with support for colors and fonts, and images!
Audio, video, and animation have been handled differently by the major browsers. Different formats have been
supported, and some formats require extra helper programs (plug-ins) to work.
Hopefully this will become history. HTML5 multimedia promises an easier future for multimedia.
Multimedia Formats
Multimedia elements (like audio or video) are stored in media files.
The most common way to discover the type of a file, is to look at the file extension.
Multimedia files have formats and different extensions like: .swf, .wav, .mp3, .mp4, .mpg, .wmv, and .avi.
Audio Formats
MP3 is the newest format for compressed recorded music. The term MP3 has become synonymous with digital
music.
If your website is about recorded music, MP3 is the choice.
Format File Description
MIDI (Musical Instrument Digital Interface). Main format for all electronic music devices
.mid like synthesizers and PC sound cards. MIDI files do not contain sound, but digital notes that
MIDI
.midi can be played by electronics. Plays well on all computers and music hardware, but not in
web browsers.
.rm RealAudio. Developed by Real Media to allow streaming of audio with low bandwidths.
RealAudio
.ram Does not play in web browsers.
WMA (Windows Media Audio). Developed by Microsoft. Commonly used in music
WMA .wma
players. Plays well on Windows computers, but not in web browsers.
AAC (Advanced Audio Coding). Developed by Apple as the default format for iTunes.
AAC .aac
Plays well on Apple computers, but not in web browsers.
WAV. Developed by IBM and Microsoft. Plays well on Windows, Macintosh, and Linux
WAV .wav
operating systems. Supported by HTML5.
Ogg .ogg Ogg. Developed by the Xiph.Org Foundation. Supported by HTML5.
MP3 files are actually the sound part of MPEG files. MP3 is the most popular format for
MP3 .mp3 music players. Combines good compression (small files) with high quality. Supported by all
browsers.
MP4 is a video format, but can also be used for audio. MP4 video is the upcoming video
MP4 .mp4
format on the internet. This leads to automatic support for MP4 audio by all browsers.
Only MP3, WAV, and Ogg audio are supported by the HTML5 standard.
Html VEDIO
Playing Videos in HTML
Before HTML5, a video could only be played in a browser with a plug-in (like flash).
The HTML5 <video> element specifies a standard way to embed a video in a web page.
Browser Support
The numbers in the table specify the first browser version that fully supports the <video> element.
Element
<video> 4.0 9.0 3.5 4.0 10.5
How it Works
The controls attribute adds video controls, like play, pause, and volume.
It is a good idea to always include width and height attributes. If height and width are not set, the page might
flicker while the video loads.
The <source> element allows you to specify alternative video files which the browser may choose from. The
browser will use the first recognized format.
The text between the <video> and </video> tags will only be displayed in browsers that do not support the
<video> element.
Browser Support
The numbers in the table specify the first browser version that fully supports the <audio> element.
Element
<audio> 4.0 9.0 3.5 4.0 10.5