An absolute URL is a full web address that includes the protocol (like https://), domain name, and the full path to a resource. It points to the exact location on the internet.
Click to reveal answer
beginner
What is a relative URL?
A relative URL points to a resource based on the current page's location. It does not include the domain name or protocol, just the path relative to the current page.
Click to reveal answer
beginner
Example of an absolute URL?
https://example.com/images/photo.jpg is an absolute URL because it includes the protocol (https://) and the full domain name.
Click to reveal answer
beginner
Example of a relative URL?
images/photo.jpg is a relative URL because it points to a file inside the 'images' folder relative to the current page.
Click to reveal answer
intermediate
Why use relative URLs instead of absolute URLs?
Relative URLs make it easier to move or copy a website to a different domain without changing all links. They also keep links shorter and simpler.
Click to reveal answer
Which URL is absolute?
Ahttps://mysite.com/about.html
Babout.html
C/images/logo.png
D../contact.html
✗ Incorrect
Only option C includes the full protocol and domain, making it an absolute URL.
What does a relative URL depend on?
AThe browser type
BThe internet speed
CThe current page's location
DThe server's IP address
✗ Incorrect
Relative URLs depend on where the current page is located to find the resource.
Which is a benefit of using relative URLs?
AThey always load faster
BLinks work even if the site domain changes
CThey include the full domain name
DThey require no folder structure
✗ Incorrect
Relative URLs make it easier to move a site without changing all links.
Which URL is relative?
A/css/styles.css
Bhttps://example.com/index.html
Chttp://example.com/page
Dhttps://cdn.example.com/script.js
✗ Incorrect
Option A starts with a slash but no domain, so it is relative to the root of the current domain.
What does an absolute URL always include?
AOnly the file extension
BOnly the file name
COnly the folder path
DProtocol and domain name
✗ Incorrect
Absolute URLs always include the protocol (like https://) and the domain name.
Explain the difference between absolute and relative URLs in your own words.
Think about whether the URL includes the full web address or just a path.
You got /3 concepts.
Why might a web developer choose to use relative URLs instead of absolute URLs?
Consider what happens if the website address changes.
You got /3 concepts.
Practice
(1/5)
1. Which of the following best describes an absolute URL?
easy
A. A link that starts with a slash, like /images/photo.jpg
B. A full web address including protocol and domain, like https://example.com/page
C. A link that points to a file in the same folder, like photo.jpg
D. A URL that only works on your local computer
Solution
Step 1: Understand what an absolute URL is
An absolute URL includes the full address: protocol (http/https), domain, and path.
Step 2: Compare options to definition
A full web address including protocol and domain, like https://example.com/page shows a full address with protocol and domain, matching the absolute URL definition.
Final Answer:
A full web address including protocol and domain, like https://example.com/page -> Option B
Quick Check:
Absolute URL = full web address [OK]
Hint: Absolute URLs always start with http:// or https:// [OK]
Common Mistakes:
Confusing relative URLs with absolute URLs
Thinking a URL starting with / is absolute
Believing file names alone are absolute URLs
2. Which of these is the correct way to write a relative URL to link to a file named style.css in the same folder?
easy
A. style.css
B. https://example.com/style.css
C. /style.css
D. ../style.css
Solution
Step 1: Understand relative URLs in the same folder
A relative URL to a file in the same folder can be just the file name.
Step 2: Check options for correct relative URL
style.css uses just style.css, which correctly points to the file in the same folder.
Final Answer:
style.css -> Option A
Quick Check:
Relative URL same folder = file name only [OK]
Hint: Use just the file name for same-folder relative URLs [OK]
Common Mistakes:
Using a leading slash which points to root folder
Using full URLs when relative is needed
Using ../ which points to parent folder
3. Given the current page URL is https://example.com/blog/post1.html, what will the browser load for the relative URL ../images/pic.jpg?
medium
A. https://example.com/images/pic.jpg
B. https://example.com/blog/images/pic.jpg
C. https://example.com/blog/post1.html/images/pic.jpg
D. https://images/pic.jpg
Solution
Step 1: Understand the meaning of .. in relative URLs
.. means go up one folder from the current page location.
Step 2: Apply to current URL
Current URL folder is /blog/. Going up one folder leads to /. Then adding images/pic.jpg gives /images/pic.jpg.
Final Answer:
https://example.com/images/pic.jpg -> Option A
Quick Check:
.. moves up one folder [OK]
Hint: .. means go up one folder in URL path [OK]
Common Mistakes:
Thinking .. stays in the same folder
Appending path without going up folder
Confusing relative with absolute URLs
4. You wrote this HTML link: <a href="images/photo.jpg">Photo</a> on the page https://example.com/about/index.html, but the image does not load. What is the likely problem?
medium
A. The URL should be absolute starting with https://
B. The relative URL is missing a leading slash to start from root
C. The file extension .jpg is incorrect
D. The relative URL points to a folder that does not exist relative to current page
Solution
Step 1: Understand relative URL resolution
The relative URL images/photo.jpg looks for an images folder inside the current folder /about/.
Step 2: Check folder existence
If the images folder is not inside /about/, the link will break. This is the likely cause.
Final Answer:
The relative URL points to a folder that does not exist relative to current page -> Option D
Quick Check:
Relative URLs depend on current folder [OK]
Hint: Check if relative folder exists where page is located [OK]
Common Mistakes:
Assuming relative URLs start from root without slash
Using absolute URLs unnecessarily
Ignoring folder structure when linking
5. You want to link to the homepage from a page at https://example.com/products/item.html. Which URL should you use to ensure the link works correctly regardless of the current page location?
hard
A. /index.html
B. index.html
C. https://example.com/index.html
D. ../index.html
Solution
Step 1: Understand absolute vs relative URL behavior
Relative URLs depend on current page location, so they may break if page moves.
Step 2: Choose URL that works anywhere
An absolute URL with full domain always works regardless of page location.
Final Answer:
https://example.com/index.html -> Option C
Quick Check:
Absolute URL works anywhere [OK]
Hint: Use full URL to avoid relative path issues [OK]
Common Mistakes:
Using relative URLs that break if page moves
Assuming leading slash always works for all pages
Not including protocol and domain for absolute URLs
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.