4. Usage
This section describes the various forms of URI references and their usage scenarios.
4.1. URI Reference
A URI reference can be either a URI or a relative reference.
URI-reference = URI / relative-ref
Key Points:
- URI references are the most general form
- Can be absolute or relative
- Used throughout web technologies
4.2. Relative Reference
A relative reference takes advantage of the hierarchical syntax (Section 3) to express a URI reference relative to another hierarchical URI.
relative-ref = relative-part [ "?" query ] [ "#" fragment ]
relative-part = "//" authority path-abempty
/ path-absolute
/ path-noscheme
/ path-empty
Examples:
../resource- parent directory./file.html- current directory?query=value- query only#fragment- fragment only
4.3. Absolute URI
An absolute URI consists of a scheme name followed by a colon, then a scheme-specific part.
absolute-URI = scheme ":" hier-part [ "?" query ]
Note: Absolute URIs do not include fragments.
4.4. Same-Document Reference
When a URI reference refers to the same document as the base URI, it is called a same-document reference. The most common form is a fragment reference.
Example: #section1
4.5. Suffix Reference
A suffix reference is a relative reference that contains only path segments and optional query and/or fragment.
Examples:
file.txtdir/file.html?key=value
Next Chapter: 5. Reference Resolution - How to resolve relative references