HTML File Paths
HTML file paths are used within an HTML page to connect and reference various resources (such as pictures, stylesheets, scripts, and so on). Absolute and relative file paths are the two primary types.
1. Absolute File Paths:
An absolute file path returns the whole URL or directory structure from the file system's root. It is generally preceded by the protocol (for example, "http://" or "https://") or the root directory ("/" for local files).
An example of an absolute route to a web image:
<img src="image.jpg" alt="Image">
2. Relative File Paths:
Relative file paths are supplied relative to the HTML file's current position. There are several methods for specifying relative paths:
a. Same Directory:
You may just provide the file name if the resource is in the same directory as the HTML file.
<img src="https://example.com/images/example.jpg" alt="Example Image">
b. Subdirectory:
If the resource is in a subfolder, the subdirectory is specified first, followed by the file name.
<img src="images/image.jpg" alt="Image">
If the resource is in a parent directory, the parent directory is indicated by "..".
<img src="../images/image.jpg" alt="Image">
1. src attribute (for images, audio, video, scripts):
<img src="path/to/image.jpg" alt="Image"> <script src="path/to/script.js"></script>
<<a href="path/to/page.html">Link</a> <link rel="stylesheet" href="path/to/styles.css">
<object data="path/to/data.json" type="application/json"></object>
Labels: HTML
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home