HTML file paths are used to link external resources such as images, scripts, and CSS files to an HTML document. File paths can be either relative or absolute.
A relative file path specifies the location of a file relative to the location of the current HTML document. For example, if an image file is located in the same directory as the HTML document, the relative file path would simply be the name of the file. If the image file is located in a subdirectory of the current directory, the relative file path would include the name of the subdirectory. If the image file is located in a parent directory, the relative file path would include the “..” notation.
An absolute file path, on the other hand, specifies the complete path to a file from the root directory of the website. Absolute file paths are generally longer and more complex than relative file paths.
Here are some examples of relative file paths:
<img src="image.jpg">
(file is located in the same directory as the HTML document)<img src="images/image.jpg">
(file is located in a subdirectory called “images”)<img src="../image.jpg">
(file is located in the parent directory of the HTML document)
And here are some examples of absolute file paths:
<img src="/images/image.jpg">
(file is located in a directory called “images” at the root of the website)<script src="https://example.com/js/script.js"></script>
(file is located on a different website and is accessed via its URL)