• 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 and Relative URLs

9 views 0

Written by admin
April 15, 2023

In HTML, URLs are used to specify the location of web resources such as web pages, images, or other files. There are two types of URLs: absolute URLs and relative URLs.

An absolute URL specifies the complete address of a web resource, including the protocol, domain name, and path. Here’s an example of an absolute URL:

https://www.example.com/images/picture.jpg

In this example, “https://” is the protocol, “www.example.com” is the domain name, and “/images/picture.jpg” is the path to the image file.

A relative URL specifies the location of a web resource relative to the current page. Relative URLs can be shorter and easier to maintain than absolute URLs because they only specify the path from the current page to the resource. Here’s an example of a relative URL:

images/picture.jpg

In this example, the path to the image file is relative to the location of the current web page.

It’s important to note that when using a relative URL, the browser will use the current page’s URL as the base URL to resolve the relative URL. If the current page’s URL changes, the relative URL may no longer work correctly. In contrast, absolute URLs always specify the complete address of the resource, so they don’t depend on the current page’s URL.

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
Link Titles
Up Next
HTML Link Tags
Copyright 2022 k-window. All Rights Reserved