On the web, an absolute URL includes a scheme and the information needed to identify its destination, such as https://example.com/images/dog.jpg. A local absolute filesystem path is a different concept, such as /Users/dan/project/index.html.
Compare the references
| Reference | Meaning |
|---|---|
https://example.com/images/dog.jpg |
Complete web URL |
/images/dog.jpg |
Root-relative reference on the current origin |
images/dog.jpg |
Relative to the current base directory |
A root-relative reference begins with a slash but does not specify a hostname. It is useful within a site, though it needs care when deploying the same content under a subdirectory.
Inspect a complete URL
HTML and CSS
HTML
<p>Inspect https://example.com/images/dog.jpg:</p>
<output></output>
<script>
const url = new URL("https://example.com/images/dog.jpg"); document.querySelector("output").textContent = "Origin: " + url.origin + " | Path: " + url.pathname;
</script>
CSS
output {
display: block;
padding: 1rem;
background: #eff6ff;
overflow-wrap: anywhere;
}
Edit HTML or CSS to update the preview as you type. Copy code snippet copies the selected tab. Preview spacing and font defaults are not included.
The inspection makes no request to the example server. A real image also needs accurate alt text, and a real link needs descriptive text; an empty anchor is not a useful copied navigation example.
Use an absolute URL for a destination on another origin or when a complete address is required. Use relative URLs when the base relationship is intentional. Neither form fixes a missing resource or grants permission to access it.
Sources
Reference 1 provide the technical details and current compatibility information.