The input tag is used to collect data in web forms and send that data to the web server. The input tag helps the server define the type of data that is being collected and may act in different ways depending upon the type of data it collects.
There are several different types of input tag:
- color (HTML 5)
- date (HTML 5)
- datetime (HTML 5)
- datetime-local (HTML 5)
- email (HTML 5)
- month (HTML 5)
- number (HTML 5)
- range (HTML 5)
- search (HTML 5)
- tel (HTML 5)
- time (HTML 5)
- url (HTML 5)
- week (HTML 5)
DTD: HTML5: <!doctype html>
HTML4 Strict: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
HTML4 Transitional or Loose: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
INPUT Web Browser Support:
Browser support of the input tag depends mostly on what type of input tag you are using. However, modern browsers (Chrome, Firefox, Internet Explorer 6+, Opera, and Safari) all support the majority of input types.
HTML 5 Concerns: The default type for the input tag is text and if the browser does not recognize the type (because it is HTML 5 or some other type), it will send it as it does a text field. Therefore, if you decide to use the additional HTML 5 input types, browsers will still support them and submit them correctly to the server.
INPUT End Tag:
The input tag is a singleton tag. It has no end or closing tag.
In XHTML, this tag must have a closing slash:
The input tag is a singleton tag and has no contents
INPUT Valid Context:
The input tag is valid within the following tags:
a, abbr, address, article, aside, b, blockquote, body, caption, cite, code, datagrid, dd, del, details, dfn, dialog, div, dt, em, fieldset, footer, form, h1, h2, h3, h4, h5, h6, header, i, iframe, ins, kbd, label, legend, li, mark, menu, noscript, object, output, p, pre, progress, q, s, samp, section, small, span, strike, strong, sub, sup, td, th, tt, u, var
The input tag is used to create form input fields. The most commonly used input tag is the text input field. It is written like this:
<input type="text" name="text box">
If you write a text box, the type attribute is not required:
<input name="text box">
View live examples of input tags.
INPUT Special Notes:
The input tag is the primary method of soliciting form data from customers. By learning how to use it effectively, you will know a lot about how to build web forms.