HTML Input Tag

The HTML <input> tag is used to represent a form input control in HTML document. This form input control facilitate user to input data and communicate with a website or application. Let’s take an example of an HTML form with three input fields, two text fields and one button for submission.

HTML Input Tag Example

Let’s see the example of HTML input tag.

<form action="#">  

First name: <input type="text" name="FirstName"  placeholder="enter firstname..."><br>  

Last name: <input type="text" name="LastName" placeholder="enter lastname..."><br>  

<input type="submit" value="Submit">  

</form>

Output:First name: 
Last name: 

Click the “Submit” button for sending the form-data to a page on the server.

Points to remember

1) Use the input element within the form element to declare input control that allow user to enter data.

2) The input element is empty. It contains attributes only. There is no need of an end tag in HTML.

3) If you want to define labels for input element, use the label element with each input tag.

Difference between HTML4.01 and HTML5

HTML5 does not support “align” attribute. There are several new attributes for <input> tag in HTML5, and the type attribute has several new values.

Difference between HTML and XHTML

In HTML, <input> tag is used without an end tag. In XHTML, the <input> tag must be properly closed.

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<input>YesYesYesYesYes

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *