A file path describes the location of a file in a web site’s folder structure. They are used to link to external files, like:
- MP3 files
- Style sheets
Absolute File Paths
URL paths in HTML can be absolute paths, like a full URL, for example:
<a href="https://www.codecademy.com/resources/docs">The URL for this anchor element is an absolute file path.</a>
Relative File Paths
Relative file path are paths that links to a local file in the same folder or on the same server, for example:
Relative file paths begin with
./ followed by a path to the local file.
./ tells the browser to look for the file path from the current folder.
<a href="./about.html">The URL for this anchor element is a relative file path.</a>
Link to a Specific Part of the Page
The anchor element
<a> can create hyperlinks to different parts of the same HTML document using the
href attribute to point to the desired location with
# followed by the
id of the element to link to.
<div><p id="id-of-element-to-link-to">A different part of the page!</p></div><!-- Later in the page ---><a href="#id-of-element-to-link-to">Take me to a different part of the page</a>
- Anonymous contributors
Learn HTML on Codecademy
- Anonymous contributorsAnonymous contributors