Home > Articles > Web Development > HTML/CSS

  • Print
  • + Share This
This chapter is from the book

Uniform Resource Locators (URLs)

How does a browser know what to request of a web server? How does your browser know which web server, of the millions in the world, to ask? The answer, as you've probably guessed, is links! A link is a reference, embedded in the content of a document, to another resource on the Web. This is the essence of hypertext media.

The destination of a link is given by a string of characters called a Uniform Resource Locator (URL). A special bit of HTML markup, called the anchor element, makes this portion of text, or that image or those buttons, "active." When you click one, your browser requests a new document from the web server indentified in the URL.

In addition to links, URLs are used in HTML to load images, video, and other online media into a page; to apply stylesheets and create pop-up windows; and to specify where form input should be sent. In HTML a URL can be in partial form, often called a relative URL. A browser fills in any missing parts of the URL from the corresponding parts of the current page's URL to create a full URL. This neat trick makes it easy to relocate a website. A full URL starts with the protocol to use for the transfer. The URL design is universal and can reference other Internet things besides Web resources. We will go into more detail later. For now, suffice it to say that the Web's protocol is HyperText Transport Protocol, abbreviated as "http" or "https" when used in a URL. The "s" means that a secure (that is, encrypted) connection is made to the web server so that nobody eavesdropping on the conversation between your browser and the web server can steal anything important, such as a credit card number. Otherwise, the https protocol works the same way as http. By having secure transactions at the protocol level, web page authors and developers can write HTML that works in either environment.

The web server address comes after the protocol designation. Following that, the path to the file or resource is given. (There's more, but this will do for now.) Thus, when you click a link whose defining anchor element2 contains a URL, such as http://www.google.com/about.html, your browser understands this as a request to open a connection to the Internet server, www.google.com, using the HTTP protocol and to get the resource, about.html.

Of course, you do not always have to click a link or button to get somewhere on the Web. You can just type a portion of a URL into the location window at the top of your browser, and you are taken there. Alternatively, you can open an HTML file from your local computer. (Web developers commonly do this when working on a website.)

  • + Share This
  • 🔖 Save To Your Account