<input/> Tag Syntax

<body>
   ...
   ... flow content expected ...
   <form id="form-id" method="GET|POST|etc." action="target-URL">
      ... phrasing content expected ...<input .../>...
      ...
   </form>
   ...
   ... phrasing content expected ...<input form="form-id"/>...
   ...
</body>
Rules for coding HTML input elements

Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.

  1. Code the input element where phrasing content is expected, usually inside a form element.
  2. The input element consists of a standalone <input/> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the xmlns attribute on the <html> tag.
  3. If the input is for a form that can be submitted but is outside that form element, include a form attribute referencing the form the input is to be associated with.
  4. Include any other attributes on the <input> tag as appropriate.
  5. Since the input element is a void element, it should always be coded as a self-closing tag terminated with the delimiter string />.

<input/> Content Model

Contents of the input element

Content: Empty. All properties are coded using attributes.

Since the <input/> tag is a void element, it is not allowed to have any content, even HTML comments and therefore should always be coded as a self-closing standalone tag, ending with the delimiters /> rather than just > (<input .../>).