What is a uniform resource locator (URL)?

A uniform resource locator is the unique address of anything published on the web.

  • Commonly referred to as the URL
  • Doesn’t necessarily have to be a webpage or website – URLs can also point to:
    • HTML pages
    • CSS documents
    • Images
    • Anything that has been published on the web regardless if it’s a website or not.

Anatomy of a URL

URL examples:

https://developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Learn#where_to_start
https://developer.mozilla.org/en-US/search?q=URL
  • Composed of mandatory and optional parts:
    • Scheme → usually HTTPS / HTTP
      • HTTP is an unsecure version of HTTPS
      • Doesn’t necessarily have to be HTTPS; browsers may have their own special types
        • Example → Firefox can use “about” as a scheme → “about:about” leads to a page that goes to other pages that use the “about” scheme accessed by Firefox
    • Authority → Includes the Domain name and the port, separated by a colon. The authority is separated from the scheme with a “://”.
      • An IP address may be in place of a domain name.
      • Ports are usually omitted if standard ports are being used.
      • Example → developer.mozilla.org
    • Path to a file/resource → Just like a path to a file in a computer, path to resources use the same kind of scheme (not like the scheme above)
      • Example → /en-US/docs/Learn
    • Parameters → Usually listed as a key with a value. Each key is separated by a “?”
      • Specific to their own web server with their own rules
      • Example → ?key1=value1&key2=value2search?q=URL
    • Anchor → Points to a specific heading in the document. Without the anchor in the URL, the page loaded goes to the topmost of the page. If there is an anchor specified, the webpage will go to the anchor instead.

Absolute vs relative vs semantic URLs

External links and sources

Related