C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
HTML File PathsAn HTML file path is used to describe the location of a file in a website folder. File paths are like an address of file for a web browser. We can link any external resource to add in our HTML file with the help of file paths such as images, file, CSS file, JS file, video, etc. The src or href attribute requires an attribute to link any external source to HTML file. Following are the different types to specify file paths:
File paths are used on webpages to link external files like:
There are two types of File Paths:
Absolute File PathsAbsolute file path specifies full URL address. Example:<!DOCTYPE html> <html> <body> <h2>Using a Full URL File Path</h2> <img src="https://www.TheDeveloperBlog.com/images/nature-1.jpg" alt="image" style="width:300px"> </body> </html> Relative File PathsThe relative file path specifies to a file which is related to the location of current page. Example:Let's take an example to see how the file path points to a file in the images folder located at the root of the current web. <!DOCTYPE html> <html> <body> <h2>Using a Relative File Path</h2> <img src="/images/nature-2.jpg" alt="Mountain" style="width:300px"> </body> </html> Example:This is how a file path points to a file in the images folder located in the current folder. <!DOCTYPE html> <html> <body> <h2>Using a Relative File Path</h2> <img src="images/nature-3.jpg" alt="Mountain" style="width:300px"> </body> </html> Example:When the images folder located in the folder one level above the current folder. <!DOCTYPE html> <html> <body> <h2>Using a Relative File Path</h2> <img src="../images/nature4.jpg" alt="Mountain" style="width:300px"> </body> </html> Important Points for File path:
Next TopicHTML Head
|