Problem Statement
What does a relative URL starting with '/' refer to?
Explanation
A relative URL starting with a forward slash refers to the root of the website. This is called a root-relative URL or absolute path from the root. For example, slash images slash photo dot jpg always refers to the images folder at the root of your website, regardless of which page you are currently on. This is different from a relative URL without the leading slash, which is relative to the current page's location. Root-relative URLs are useful because they work consistently across your entire website. If you move pages around, root-relative URLs do not break as easily as page-relative URLs. Understanding the difference between root-relative and page-relative URLs is important for maintaining large websites.
Code Solution
SolutionRead Only
<!-- Root-relative URL (starts from website root) --> <a href="/about.html">About</a> <a href="/images/logo.png">Logo</a> <a href="/contact/form.html">Contact</a> <!-- Page-relative URL (relative to current page) --> <a href="about.html">About</a> <a href="images/logo.png">Logo</a> <a href="../contact.html">Contact (parent folder)</a>
