HTML/Elements/input/url

From Web Education Community Group
< HTML‎ | Elements‎ | input
Jump to: navigation, search

<input type="url">

The url state represents a control for editing a single absolute URL given in the element's value.

Point

  • The value attribute, if specified, must have a value that is a valid URL potentially surrounded by spaces that is also an absolute URL.


  • While the value of the element is not a valid absolute URL, the element is suffering from a type mismatch.


HTML Attributes

  • autocomplete = on/ off/ defult
    • on
      The on state indicates that the value is not particularly sensitive and the user can expect to be able to rely on his user agent to remember values he has entered for that control.
    • off
      The off state indicates either that the control's input data is particularly sensitive (for example the activation code for a nuclear weapon); or that it is a value that will never be reused (for example a one-time-key for a bank login) and the user will therefore have to explicitly enter the data each time, instead of being able to rely on the UA to prefill the value for him; or that the document provides its own autocomplete mechanism and does not want the user agent to provide autocompletion values.
    • defult
      The default state indicates that the user agent is to use the autocomplete attribute on the element's form owner instead. (By default, the autocomplete attribute of form elements is in the on state.)


  • list = ID reference
    Identify an element that lists predefined options suggested to the user.
    If present, its value must be the ID of a datalist element in the same document.


  • maxlength = positive integer
    Gives the maximum allowed value length of the element.


  • name = string
    Gives the name of the input element.


  • pattern =
    Specifies a regular expression against which the control's value is to be checked.
    If specified, the attribute's value must match the JavaScript Pattern production.
    When an input element has a pattern attribute specified, authors should include a title attribute to give a description of the pattern.


  • placeholder = string
    Represents a short hint (a word or short phrase) intended to aid the user with data entry.
    A hint could be a sample value or a brief description of the expected format. For a longer hint or other advisory text, the title attribute is more appropriate.


  • readonly = boolean
    Controls whether or not the user can edit the form control.


  • required = boolean
    When specified, the element is required.


  • size = valid non-negative integer
    The number of options meant to be shown by the control represented by its element.


  • value = string
    Gives the default value of the input element.


Examples

Example A

If a document contained the following markup [try it]:

<input type="url" name="location" list="urls">
<datalist id="urls">
  <option label="MIME: Format of Internet Message Bodies" value="http://tools.ietf.org/html/rfc2045">
  <option label="HTML 4.01 Specification" value="http://www.w3.org/TR/html4/">
  <option label="Form Controls" value="http://www.w3.org/TR/xforms/slice8.html#ui-commonelems-hint">
  <option label="Scalable Vector Graphics (SVG) 1.1 Specification" value="http://www.w3.org/TR/SVG/">
  <option label="Feature Sets - SVG 1.1 - 20030114" value="http://www.w3.org/TR/SVG/feature.html">
  <option label="The Single UNIX Specification, Version 3" value="http://www.unix-systems.org/version3/">
</datalist>

HTML Reference

The HTML5 specification defines the Url state in 4.10.7.1.4 URL STATE.