• HTML
  • React
  • Knowledge Base
  • HTML
  • React
  • Knowledge Base
  • HTML Tutorial
  • HTML Styles – CSS
  • Link to an Email Address
  • HTML Introduction
  • HTML Editors
  • HTML Basic Examples
  • HTML Elements
  • HTML Attributes
  • HTML Headings
  • HTML Paragraphs
  • HTML Styles
  • HTML Text Formatting
  • HTML Quotation and Citation Elements
  • HTML Comments
  • HTML Colors
  • HTML RGB and RGBA Colors
  • HTML HEX Colors
  • HTML HSL and HSLA Colors
  • CSS Colors, Fonts and Sizes
  • CSS Padding
  • CSS Border
  • CSS Margin
  • Link to External CSS
  • HTML Style Tags
  • HTML Links
  • HTML Links – The target Attribute
  • Absolute URLs vs. Relative URLs
  • HTML Links – Use an Image as a Link
  • Button as a Link
  • Link Titles
  • Absolute URLs and Relative URLs
  • HTML Link Tags
  • HTML Links – Different Colors
  • Link Buttons
  • HTML Links – Create Bookmarks
  • The alt Attribute
  • HTML Images
  • Image Size – Width and Height
  • Image Width and Height, or Style
  • Images in Another Folder
  • HTML Images on Another Server/Website
  • HTML Animated Images
  • Image as a Link
  • Image Floating
  • Common Image Formats
  • HTML Image Tags
  • The render Method

Absolute URLs vs. Relative URLs

8 views 0

Written by admin
April 15, 2023

In HTML, URLs (Uniform Resource Locators) are used to specify the location of web pages, images, and other resources on the internet. There are two types of URLs: absolute URLs and relative URLs.

Absolute URLs specify the complete web address of a resource, including the protocol (http or https), domain name, and path to the resource. For example, an absolute URL for the home page of Google would be:

https://www.google.com/

Relative URLs, on the other hand, specify the location of a resource relative to the current web page. Relative URLs are often shorter and more convenient to use than absolute URLs, especially when linking to other pages within the same website. For example, a relative URL for the About page on a website might be:

/about.html

In this example, the resource is located in the same directory as the current page, so the relative URL specifies only the file name.

Relative URLs can also include directory names to specify the location of the resource relative to the current page. For example, a relative URL for a page located in a subdirectory of the current page might be:

/subdirectory/page.html

In general, it is a good practice to use relative URLs whenever possible, especially when linking to pages within the same website. Relative URLs make it easier to move or rename pages within a website without having to update all of the links on the site. However, there are cases where absolute URLs are necessary, such as when linking to resources on external websites or when using links in email campaigns or social media posts.

Was this helpful?

Yes  No
Related Articles
  • The render Method
  • HTML Image Tags
  • Common Image Formats
  • Image Floating
  • Image as a Link
  • HTML Animated Images

Didn't find your answer? Contact Us

Leave A Comment Cancel reply

Previously
HTML Links – The target Attribute
Up Next
HTML Links – Use an Image as a Link
Copyright 2022 k-window. All Rights Reserved