URL input (type="url")

HTML Living Standard

Collect a web address. A nonempty value must have a valid absolute URL format to pass native validation.

On this page

Attributes and behavior

Value or syntaxWhat it does
placeholder="https://example.com"Shows the expected URL format.
patternAdds a pattern the entire nonempty value must match.
requiredAn empty field prevents a normal validated submission.

Try the example

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>URL input</title>
  <style>
form { display: grid; gap: 12px; justify-items: start; } output { display: block; margin-top: 10px; }
  </style>
</head>
<body>
<form id="demo">
  <label>Website <input type="url" name="website" placeholder="https://example.com" required></label>
  <button type="submit">Check</button>
</form>
<output id="response"></output>
  <script>
const form = document.querySelector('#demo');
form.addEventListener('click', event => {
  const submitter = event.target.closest('[type="submit"], [type="image"]');
  if (!submitter) return;
  event.preventDefault();
  if (!form.noValidate && !submitter.formNoValidate && !form.reportValidity()) return;
  const values = new FormData(form, submitter);
  document.querySelector('#response').textContent =
    'Passed validation. Fields received: ' + [...values.keys()].join(', ');
});
  </script>
</body>
</html>

What to expect Try example.com, then try https://example.com. The second has a URL scheme.

Official references