Last Updated : 20 May, 2024
The HTML <input type="url"> element is used to create an input field for entering a URL. It provides validation for URLs, ensuring that the value entered is a properly formatted web address. This element helps improve user experience by guiding users to enter valid URLs in web forms.
Syntax<input type="url">
Example: This example demonstrates the use of HTML <input type="url"> element.
HTML
<!DOCTYPE html>
<html>
<head>
<title>HTML Input Type URL</title>
</head>
<body style="text-align:center;">
<h2>HTML <input type="URL"></h2>
<form action="#">
<label for="website_name">Website Name:</label>
<input type="text" id="website_name" required>
<br><br>
<label for="website_url">Website URL:</label>
<input type="url" id="website_url"
placeholder="https://geeksforgeeks.org"
pattern="https://.*" size="30" required />
<br><br>
<input type="submit" value="Click Here!">
</form>
</body>
</html>
Output
Supported BrowsersRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4