HTML lesson – What are URLs?

HTML lesson – What are URLs? cover image
  1. Home
  2. HTML
  3. HTML lesson – What are URLs?

(Note: If you are new to Internet you should first read the URL Basics section, which discusses URLs in general and come back to this page.)

What are URLs?

Let’s dissect this URL:
//www.webdevelopersnotes.comhtml-lesson-what-are-urls

It refers to file html_lesson_what_are_urls.php3 located in html subdirectory inside tutorials directory found at www.webdevelopersnotes.com.

Note: The domain name www.webdevelopersnotes.com is not case sensitive but the directory and files names are. (This is especially true for Unix based systems).

URLs are often used as values for HREF attribute of the <A> tag. Now, if I want to link to the next section (free_html_lesson_how_to_include_images_in_web_pages_part_1.php3) I can use either “https://www.webdevelopersnotes.com/tutorials/html/ free_html_lesson_how_to_include_images_in_web_pages_part_1.php3” or simply “free_html_lesson_how_to_include_images_in_web_pages_part_1.php3”.
So what is the difference? The former is the complete path of the file while the latter is a relative (relative to this document) path. Since I know that the next page is located in the same directory, I choose to use a relative URL. This helps me in site maintenance and I don’t have to type the long address always.

When I want to refer to the homepage of webdevelopersnotes.com from this directory, I use the relative URL “../../index.html” inside HREF. This is a standard Unix notation of referring to URLS. It tells the browser to first come out of the html directory (../) into tutorials directory and from there move, to the next top directory (another ../) which is the root directory of my web-site and then display index.html file.

<A HREF="../../index.html">Homepage<A>

Homepage will take you to the main page of this web-site.

HTML