A Uniform Resource Locator (URL), colloquially termed a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identifier (URI).
â URL - Wikipedia
The SyntaxAs a URL is a specific type of URI, it conforms to the syntax of a generic URI, which is of the form:
scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]
And there are some points regarding the use of slash:
//
): This is required by some schemes and not required by some others. In the case of URL, there is a host specified, thus the two slashes are required./
) if an authority part ([//[user[:password]@]host[:port]]
) was present, and may also if one was not, but must not begin with a double slash.So we know that, by definition, forward slashes (/) should be used in URLs
However, in reality, browsers are tolerant enough to accept URLs written with backslashes and even mixed slashes.
Here is a JSFiddle to test URLs written with various forms of slashes, and screenshots of the results on Firefox and Edge.
I've tested it on IE, Edge, Firefox, Chrome and Safari. And found that all those browsers accept URLs written with forward slashes (/
, the correct form), URLs written with backslashes (\
, an incorrect form) and URLs written with mixed slashes in their path part (/
& \
, another incorrect form).
Besides, Firefox, Chrome and Safari even accept mixed slashes used after the protocol part (e.g. http:/\
, https:\/
), while IE and Edge do not accept this use.
A side note here: \
is not speical in HTML and requires no escaping.
Now we know that, even if we write URLs in incorrect syntax, browsers will still recognize them.
However, it's alwasys good to follow the standard. Learning how browsers work in reality is for help in coding and debugging rather than advocating doing things the wrong way.
Further ReadingsRetroSearch 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.3