HTML 5 < input > Tag

HTML 5 <input> Tag with Example: In HTML 5 document, the <input> tag is used to control the form input elements. These form input elements allow users to communicate with the application or web site. Let’s consider an example of an HTML document with three input fields which is one button used to submit and two text fields to accept the full name of the user.



The HTML 5 <input> Tag Example

<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>

The <input> Tag in HTML 5 OutputHTML 5 <input> Tag Output

Click on the “submit” button to send data to the web server.

NOTE:
1. Always use input elements with the form elements to accept the user’s data.
2. The input element only contains attributes that don’t need an end tag.
3. To define labels in the HTML document, then use the label element with the input tag.

Difference between HTML 4 and HTML 5

The “align” attribute does not work in HTML5. The HTML 5 has more number of new attributes with new values for <input> tag.

Difference between HTML and XHTML

The <input> tag in HTML does not required closing tag where as in XHTML the <input> tag must close properly.

The <input> Tag Browsers Compatibility

  • Google Chrome
  • Mozilla Firefox
  • Opera
  • Safari
  • Internet Explorer