What is a URL? - Learn web development | MDN (2024)

This article discusses Uniform Resource Locators (URLs), explaining what they are and how they're structured.

Prerequisites: You need to first know how the Internet works, what a Web server is and the concepts behind links on the web.
Objective: You will learn what a URL is and how it works on the Web.

Summary

A URL (Uniform Resource Locator) is the address of a unique resource on the internet. It is one of the key mechanisms used by browsers to retrieve published resources, such as HTML pages, CSS documents, images, and so on.

In theory, each valid URL points to a unique resource. In practice, there are some exceptions, the most common being a URL pointing to a resource that no longer exists or that has moved. As the resource represented by the URL and the URL itself are handled by the Web server, it is up to the owner of the web server to carefully manage that resource and its associated URL.

Basics: anatomy of a URL

Here are some examples of URLs:

https://developer.mozilla.orghttps://developer.mozilla.org/en-US/docs/Learn/https://developer.mozilla.org/en-US/search?q=URL

Any of those URLs can be typed into your browser's address bar to tell it to load the associated resource, which in all three cases is a Web page.

A URL is composed of different parts, some mandatory and others optional. The most important parts are highlighted on the URL below (details are provided in the following sections):

What is a URL? - Learn web development | MDN (1)

Note: You might think of a URL like a regular postal mail address: the scheme represents the postal service you want to use, the domain name is the city or town, and the port is like the zip code; the path represents the building where your mail should be delivered; the parameters represent extra information such as the number of the apartment in the building; and, finally, the anchor represents the actual person to whom you've addressed your mail.

Note: There are some extra parts and some extra rules regarding URLs, but they are not relevant for regular users or Web developers. Don't worry about this, you don't need to know them to build and use fully functional URLs.

Scheme

What is a URL? - Learn web development | MDN (2)

The first part of the URL is the scheme, which indicates the protocol that the browser must use to request the resource (a protocol is a set method for exchanging or transferring data around a computer network). Usually for websites the protocol is HTTPS or HTTP (its unsecured version). Addressing web pages requires one of these two, but browsers also know how to handle other schemes such as mailto: (to open a mail client), so don't be surprised if you see other protocols.

Authority

What is a URL? - Learn web development | MDN (3)

Next follows the authority, which is separated from the scheme by the character pattern ://. If present the authority includes both the domain (e.g. www.example.com) and the port (80), separated by a colon:

  • The domain indicates which Web server is being requested. Usually this is a domain name, but an IP address may also be used (but this is rare as it is much less convenient).
  • The port indicates the technical "gate" used to access the resources on the web server. It is usually omitted if the web server uses the standard ports of the HTTP protocol (80 for HTTP and 443 for HTTPS) to grant access to its resources. Otherwise it is mandatory.

Note: The separator between the scheme and authority is ://. The colon separates the scheme from the next part of the URL, while // indicates that the next part of the URL is the authority.

One example of a URL that doesn't use an authority is the mail client (mailto:foobar). It contains a scheme but doesn't use an authority component. Therefore, the colon is not followed by two slashes and only acts as a delimiter between the scheme and mail address.

Path to resource

What is a URL? - Learn web development | MDN (4)

/path/to/myfile.html is the path to the resource on the Web server. In the early days of the Web, a path like this represented a physical file location on the Web server. Nowadays, it is mostly an abstraction handled by Web servers without any physical reality.

Parameters

What is a URL? - Learn web development | MDN (5)

?key1=value1&key2=value2 are extra parameters provided to the Web server. Those parameters are a list of key/value pairs separated with the & symbol. The Web server can use those parameters to do extra stuff before returning the resource. Each Web server has its own rules regarding parameters, and the only reliable way to know if a specific Web server is handling parameters is by asking the Web server owner.

Anchor

What is a URL? - Learn web development | MDN (6)

#SomewhereInTheDocument is an anchor to another part of the resource itself. An anchor represents a sort of "bookmark" inside the resource, giving the browser the directions to show the content located at that "bookmarked" spot. On an HTML document, for example, the browser will scroll to the point where the anchor is defined; on a video or audio document, the browser will try to go to the time the anchor represents. It is worth noting that the part after the #, also known as the fragment identifier, is never sent to the server with the request.

How to use URLs

Any URL can be typed right inside the browser's address bar to get to the resource behind it. But this is only the tip of the iceberg!

The HTML language — which will be discussed later on — makes extensive use of URLs:

  • to create links to other documents with the <a> element;
  • to link a document with its related resources through various elements such as <link> or <script>;
  • to display media such as images (with the <img> element), videos (with the <video> element), sounds and music (with the <audio> element), etc.;
  • to display other HTML documents with the <iframe> element.

Note: When specifying URLs to load resources as part of a page (such as when using the <script>, <audio>, <img>, <video>, and the like), you should generally only use HTTP and HTTPS URLs, with few exceptions (one notable one being data:; see Data URLs). Using FTP, for example, is not secure and is no longer supported by modern browsers.

Other technologies, such as CSS or JavaScript, use URLs extensively, and these are really the heart of the Web.

Absolute URLs vs. relative URLs

What we saw above is called an absolute URL, but there is also something called a relative URL. The URL standard defines both — though it uses the terms absolute URL string and relative URL string, to distinguish them from URL objects (which are in-memory representations of URLs).

Let's examine what the distinction between absolute and relative means in the context of URLs.

The required parts of a URL depend to a great extent on the context in which the URL is used. In your browser's address bar, a URL doesn't have any context, so you must provide a full (or absolute) URL, like the ones we saw above. You don't need to include the protocol (the browser uses HTTP by default) or the port (which is only required when the targeted Web server is using some unusual port), but all the other parts of the URL are necessary.

When a URL is used within a document, such as in an HTML page, things are a bit different. Because the browser already has the document's own URL, it can use this information to fill in the missing parts of any URL available inside that document. We can differentiate between an absolute URL and a relative URL by looking only at the path part of the URL. If the path part of the URL starts with the "/" character, the browser will fetch that resource from the top root of the server, without reference to the context given by the current document.

Let's look at some examples to make this clearer. Let's assume that the URLs are defined from within the document located at the following URL: https://developer.mozilla.org/en-US/docs/Learn.

https://developer.mozilla.org/en-US/docs/Learn itself is an absolute URL. It has all necessary parts needed to locate the resource it points to.

All of the following URLs are relative URLs:

  • Scheme-relative URL: //developer.mozilla.org/en-US/docs/Learn — only the protocol is missing. The browser will use the same protocol as the one used to load the document hosting that URL.
  • Domain-relative URL: /en-US/docs/Learn — the protocol and the domain name are both missing. The browser will use the same protocol and the same domain name as the one used to load the document hosting that URL.
  • Sub-resources: Common_questions/Web_mechanics/What_is_a_URL — the protocol and domain name are missing, and the path doesn't begin with /. The browser will attempt to find the document in a subdirectory of the one containing the current resource. In this case, we really want to reach this URL: https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Web_mechanics/What_is_a_URL.
  • Going back in the directory tree: ../CSS/display — the protocol and domain name are missing, and the path begins with ... This is inherited from the UNIX file system world — to tell the browser we want to go up by one level. Here we want to reach this URL: https://developer.mozilla.org/en-US/docs/Learn/../CSS/display, which can be simplified to: https://developer.mozilla.org/en-US/docs/CSS/display.
  • Anchor-only: #semantic_urls - all parts are missing except the anchor. The browser will use the current document's URL and replace or add the anchor part to it. This is useful when you want to link to a specific part of the current document.

Semantic URLs

Despite their very technical flavor, URLs represent a human-readable entry point for a website. They can be memorized, and anyone can enter them into a browser's address bar. People are at the core of the Web, and so it is considered best practice to build what is called semantic URLs. Semantic URLs use words with inherent meaning that can be understood by anyone, regardless of their technical know-how.

Linguistic semantics are of course irrelevant to computers. You've probably often seen URLs that look like mashups of random characters. But there are many advantages to creating human-readable URLs:

  • It is easier for you to manipulate them.
  • It clarifies things for users in terms of where they are, what they're doing, what they're reading or interacting with on the Web.
  • Some search engines can use those semantics to improve the classification of the associated pages.

See also

Data URLs: URLs prefixed with the data: scheme, allow content creators to embed small files inline in documents.

What is a URL? - Learn web development | MDN (2024)

FAQs

What is a URL? - Learn web development | MDN? ›

A URL (Uniform Resource Locator) is the address of a unique resource on the internet. It is one of the key mechanisms used by browsers to retrieve published resources, such as HTML pages, CSS documents, images, and so on. In theory, each valid URL points to a unique resource.

What is URL in web development? ›

A uniform resource locator (URL), colloquially known as an address on the Web, is a reference to a 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), although many people use the two terms interchangeably.

What is an URL example? ›

A URL is a specific type of URI that not only identifies a resource, but also provides the means of locating it. For example, https://www.example.com/page.html is a URL that tells you the resource is the webpage located on example.com's server at /page. html. And uses the HTTPS protocol to access it.

What is an example of a URL path? ›

A path is the unique, last part of the URL for a specific function or piece of content. For example, for a page whose full URL is http://example.com/node/7, the path is node/7.

What can you learn from a URL? ›

A URL contains important information that can help you identify the type of website it will take you to. In the graphic below, you can see that a URL is made up of three main parts: a scheme (https:// or http://), a domain name (www.oppl.org/), and a path (use-your-library/digital-learning, in this case).

How to create a URL? ›

Answer: To create a URL, register a domain name with a domain registrar, set up hosting for your website, and then link the domain to your website's IP address through your hosting provider's control panel.

What is a URL in HTML with an example? ›

HTML Uniform Resource Locators. A URL is another word for a web address. A URL can be composed of words (e.g. w3schools.com), or an Internet Protocol (IP) address (e.g. 192.68.20.50). Most people enter the name when surfing, because names are easier to remember than numbers.

What is a good URL example? ›

Some examples of great URLs are: www.hubspot.com/blog - Clear and direct, tells you exactly what to expect. www.nytimes.com - Includes the brand name, easy to remember. www.amazon.com/books - Includes a category, helps with navigation.

What is the difference between a link and a URL? ›

In everyday speech, “URL” and “link” are often used interchangeably. Strictly speaking, however, they are different – a link describes the function, which is to take you from one place on the internet to another, while the URL describes the location itself, the place you want to go.

How do I find my website URL? ›

Get a page URL

At the top of your browser, click the address bar to select the entire URL. Copy.

What are the three main parts of a URL? ›

A simple website URL should have at least three components: protocol, domain name, and path. Complex website URLs may contain up to nine. The nine parts of a complex URL are the protocol, sub-domain, domain name, port, path, query, parameters, and fragment.

What is the difference between URL and HTTP? ›

A URL is the unique resource, which can be a CSS document or an HTML webpage. HTTP, HTTPS, FTP are the protocols used with the URLs to access the resources. It also indicates the address of a webpage that we type into the space bar.

Is IP address a part of URL? ›

The URL contains the name of the protocol needed to access a resource, as well as a resource name. The first part of a URL identifies what protocol to use as the primary access medium. The second part identifies the IP address or domain name -- and possibly subdomain -- where the resource is located.

What is a URL and give an example? ›

URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the Internet. A URL has two main components: Protocol identifier: For the URL http://example.com , the protocol identifier is http . Resource name: For the URL http://example.com , the resource name is example.com .

What is a URL for dummies? ›

A URL (Uniform Resource Locator) is the address of a unique resource on the internet. It is one of the key mechanisms used by browsers to retrieve published resources, such as HTML pages, CSS documents, images, and so on. In theory, each valid URL points to a unique resource.

What is the main purpose of the URL? ›

URL stands for Uniform Resource Locator, and is used to specify addresses on the World Wide Web. A URL is the fundamental network identification for any resource connected to the web (e.g., hypertext pages, images, and sound files). The protocol specifies how information from the link is transferred.

How do I find my URL? ›

On your computer, go to google.com. Search for the page. At the top of your browser, click the address bar to select the entire URL. Copy.

What is HTTP and URL? ›

The HTTP stands for Hyper Text Transfer Protocol and the URLS stands for Uniform Resource Locator. The URL is the web address of the particular website while the HTTP is the actual resource locator or a server.

What is the URL of your site? ›

URL stands for “uniform resource locator.” A URL is the location of a web page or file that's been added to the internet. You can see a web page's URL in the address bar of your web browser.

What is domain and URL? ›

A domain is the unique name that identifies a website on the internet, while a URL (Uniform Resource Locator) is the specific address of a webpage within that domain.

Top Articles
16 Best Investing Books of All Time: Your Comprehensive Guide
3 Ways To Make Money In Your Sleep
Maxtrack Live
Walgreens Harry Edgemoor
It may surround a charged particle Crossword Clue
El Paso Pet Craigslist
Mrh Forum
³µ¿Â«»ÍÀÇ Ã¢½ÃÀÚ À̸¸±¸ ¸íÀÎ, ¹Ì±¹ Ķ¸®Æ÷´Ï¾Æ ÁøÃâ - ¿ù°£ÆÄ¿öÄÚ¸®¾Æ
9192464227
Comcast Xfinity Outage in Kipton, Ohio
Monticello Culver's Flavor Of The Day
Nieuwe en jong gebruikte campers
Rls Elizabeth Nj
Natureza e Qualidade de Produtos - Gestão da Qualidade
Missing 2023 Showtimes Near Landmark Cinemas Peoria
Springfield Mo Craiglist
TS-Optics ToupTek Color Astro Camera 2600CP Sony IMX571 Sensor D=28.3 mm-TS2600CP
Cvb Location Code Lookup
How To Cut Eelgrass Grounded
Operation Cleanup Schedule Fresno Ca
Gdp E124
Best Forensic Pathology Careers + Salary Outlook | HealthGrad
Saatva Memory Foam Hybrid mattress review 2024
Leccion 4 Lesson Test
Kringloopwinkel Second Sale Roosendaal - Leemstraat 4e
Munis Self Service Brockton
California Online Traffic School
Barista Breast Expansion
Booknet.com Contract Marriage 2
Dashboard Unt
1979 Ford F350 For Sale Craigslist
Marokko houdt honderden mensen tegen die illegaal grens met Spaanse stad Ceuta wilden oversteken
manhattan cars & trucks - by owner - craigslist
Martins Point Patient Portal
Hannah Jewell
Southtown 101 Menu
+18886727547
Skip The Games Ventura
Games R Us Dallas
Aliciabibs
The Syracuse Journal-Democrat from Syracuse, Nebraska
My.lifeway.come/Redeem
22 Golden Rules for Fitness Beginners – Barnes Corner Fitness
About Us
Embry Riddle Prescott Academic Calendar
Random Animal Hybrid Generator Wheel
25 Hotels TRULY CLOSEST to Woollett Aquatics Center, Irvine, CA
Wzzm Weather Forecast
Product Test Drive: Garnier BB Cream vs. Garnier BB Cream For Combo/Oily Skin
Craigslist Indpls Free
Optimal Perks Rs3
Latest Posts
Article information

Author: Pres. Lawanda Wiegand

Last Updated:

Views: 6354

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Pres. Lawanda Wiegand

Birthday: 1993-01-10

Address: Suite 391 6963 Ullrich Shore, Bellefort, WI 01350-7893

Phone: +6806610432415

Job: Dynamic Manufacturing Assistant

Hobby: amateur radio, Taekwondo, Wood carving, Parkour, Skateboarding, Running, Rafting

Introduction: My name is Pres. Lawanda Wiegand, I am a inquisitive, helpful, glamorous, cheerful, open, clever, innocent person who loves writing and wants to share my knowledge and understanding with you.