CKTIS / HTML
HTML concept: relative-urls
A relative URL describes a target against a document base URL, so identical text can resolve differently at another location.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
relative URL reference + document base URL → absolute URLURL attributes such as href, src, and action are parsed against the applicable base; the first addressed base can change it.
/ starts at the origin root, //host/path inherits the scheme, ?q=1 changes the query, #part the fragment, and .. removes a path segment.
Without base, the document fallback base URL exposed by document.baseURI applies; new URL(relative, base) uses the same resolution model.
The example resolves ../guide?mode=full#intro and ?q=html against document.baseURI, exposing separate path, query, and fragment effects.
Examples
<!doctype html>
<meta charset="utf-8">
<base href="https://example.test/docs/v2/">
<a id="guide" href="../guide?mode=full#intro">Guide</a>
<form id="search" action="?q=html"></form>
<output id="result"></output>
<script>
const link = document.querySelector("#guide");
const form = document.querySelector("#search");
result.textContent = `base=${document.baseURI}; link=${link.href}; form=${form.action}; path=${link.pathname}`;
</script>
Result
base=https://example.test/docs/v2/; link=https://example.test/docs/guide?mode=full#intro; form=https://example.test/docs/v2/?q=html; path=/docs/guide
The result verifies DOM URL resolution; it neither fetches resources nor proves that a destination exists.