SIGN UP MEMBER LOGIN:    
ARTICLE

Input Tag in HTML5

Posted by Rohatash Kumar Articles | HTML 5 September 20, 2011
The HTML input tag is used to display control elements that allow users to input data in a form.
Reader Level:

The input tag is used to collect data in web forms and send that data to the web server or The HTML input tag is used to display control elements that allow users to input data in a form. Using the input tag, you can add controls such as text input, radio buttons, checkbox controls, submit buttons, and more.

1. Text Input Tag

The most commonly used input tag is the text input field. This value defines a control designed for text input. This type of field allow users to input textual data (e.g., names, titles,

etc).

<input type="text" name="text box">

If you write a text box, the type attribute is optional.

<input name="text box"> 

For example

<html>

<head>

<title>

Input text in html.

</title>

</head>

<body>

User Name:

<input type="text" name="text box">

 <br />

  Email:

 <input type="text" name="text box">

 <br />

 &nbsp;<input type="button" name="btn" value="Submit" />

</body>

<body>

 

OUTPUT


img2.gif

 

2. Button Input Tag

 

You can use the Button Input tag to create a button.

 

For Example

 

In the below example we create button type input tag and create a JavaScript function and call it on the Button.

 

<html>

<head>

<title>

Input text in html.

</title>

 <script type="text/javascript">

     function btnonclick() {

         alert('This is Button type input');

     }

        </script>

 

</head>

<body>

<input type="button" name="btn" value="Button" onclick="javascript:btnonclick()"/>

</body>

</html>

 

OUTPUT


img8.gif

3. Password Input Tag

Password control is similar to text type with a small difference password types usually hide the characters inputted using dots or asterisks instead.

<input type="password" name="text box">

For example

<html>

<head>

<title>

Input text in html.

</title>

</head>

<body>

<input type="password" name="text box">

</body>

<body>

OUTPUT

img3.gif

4. Checkbox Input Tag

You can use the Checkbox Input tag to create a clickable a checkbox used for check and uncheck values. You can use as many of these in a form as you like. Use the "checked" attribute to specify if the checkbox should be checked ("on") by default. 

<html>

<head>

<title>

Input text in html.

</title>

</head>

<body>

<input type="checkbox" name="chk" value="" checked>

 Do you want the newsletter?

</input>

</body>

<body>

OUTPUT

img4.gif

5. Radio Button Input Tag

This is similar to the checkbox except that we can select only one Radio Button at a time from group of Radio Button.

<html>

<head>

<title>

Radio button Input text in html.

</title>

</head>

<body>

<input type="radio" name="rd1" value="Mag1">

            Magazine 1

        </input>

        <input type="radio" name="rd1" value="Mag2">

            Magazine 2

        </input>

        <input type="radio" name="rd1" value="Mag3" checked >

            Magazine 3

        </input>

        <input type="radio" name="rd1" value="Mag4">

            Magazine 4

        </input>

</body>

</HTML>


OUTPUT


img5.gif

6. Reset Input Tag

The Reset input tag type to clear all the data on the input tags in the form.

For example

We take a text type and reset type tag when we enter input in text tag and click on the reset type to reset the input from text tag.

<html>
<
head>
<
title>
Input text in html.
</title>
</
head>
<
body>
<
input type="text" value="This is a input tag" />
<input type="reset" value="Reset the form" />
</body>
</
html>

OUTPUT

img6.gif

7. File Input Tag

File input tag to send files on a users computer to the server when the form is submitted. This input tag displays a browse button to allow a user to browse to the file to upload (send to the server).

For Example

<html>

<head>

<title>

Input text in html.

</title>

</head>

<body>

<input type="file" name="file1" />

</body>

</html>

OUTPUT

img7.gif

8. Image

The Image input tag to use an image instead of the standard submit button.

<html>

<head>

<title>

Input text in html.

</title>

</head>

<body>

<input type="image" src="images/Sunset.jpg" style="height: 173px; width: 205px" />

</body>

</html>

 

OUTPUT


img1.gif

Login to add your contents and source code to this article
share this article :
post comment
 

Thank you pradip.

Posted by Rohatash Kumar Sep 23, 2011

Good to get basic knowledge about Input Tag in HTML5

Posted by Pradip Pandey Sep 23, 2011

Sweta, Yes, reset input tag is used for clear the value of the control in current page. You can follow below code. <html> <head> <title>My Page</title> </head> <body> <form> <div> <br><br> <input type="text" size="25" value=""> <br><input type="reset" value="Reset!"><br> </div> </form> </body> </html>

Posted by Rohatash Kumar Sep 23, 2011

Hi Rohatash, whether this Reset input tag clearsthe values of all Control in current page.

Posted by Shweta Kuthi Sep 23, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Team Foundation Server Hosting
Become a Sponsor