w3resource

HTML input tag and element

1. HTML input element is used to represent a control in an HTML form.

2. Depending upon the value of the type attribute, input control can be used to collect text, password, upload files, submit or reset a form.

3. input element starts with a <input> tag, the end tag is forbidden.

Syntax

<input ........ />

Category

HTML input element belongs to HTML forms.

Whether both start and end tags are required

The start tag is required, the end tag is forbidden.

Can contain

HTML input element can not contain any other HTML element.

Can reside within

HTML input element can reside within inline elements and other block level elements.

Attributes

Identifiers

id, class.

language information and text direction

lang, dir.

Title

Title.

Style

Style.

Alternate text

alt.

Alignment

align.

Valid content types

accept.

Read-only input controls

readonly.

Disabled input controls

disabled.

Tabbing navigation

tabindex.

Access keys

accesskey.

Client-side image maps

usemap.

Server-side image maps

ismap.

Events

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout onkeypress, onkeydown, onkeyup.

Supported doctypes

HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.

Controls which can be created with input

text, password, checkbox, radio, submit, image, reset, button, hidden, file.

Example of using HTML input element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  <html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML input tag example - HTML tutorial | w3resource</title>
</head>
<body>
<form name="example_input" action="html-input-tag-example.html">
Name: <input type="text" size="30" /><br /><br />
password: <input type="password" size="30" /><br /><br />
Place: <input type="text" size="10" /><br /><br />
<input type="radio" name="sex" value="Male" /> Male<br /><br />
<input type="radio" name="sex" value="Female" /> Female<br /><br />
Upload your photograph <INPUT type="file" name="photo">
<input type="submit" value="Send" /> <input type="reset" />
</form>
</body>
</html>

Result

html input element

View this example in a separate browser window

HTML input tag example.

Previous: HTML form tag and element
Next: HTML button tag and element

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/html/input/HTML-input-tag-and-element.php