What are the types of HTML file paths?

青灯夜游
Release: 2018-12-20 13:51:12
Original
7240 people have browsed it

There are two types of HTML file paths: absolute file paths and relative file paths.

HTML file path is used to describe the location of the files in the website folder. It is used to link external files on the web page, such as: other HTML files (web pages), pictures (using the What are the types of HTML file paths? tag or background attribute), css style sheet (using tag), JavaScript file (using <script> tag), etc. Let's take a look at how to set the two types of file paths. I hope it will be helpful to you. [Video tutorial recommendation: <a href="http://www.php.cn/course/list/11.html" target="_blank">HTML tutorial]</script>

What are the types of HTML file paths?

##Absolute file path

The absolute file path refers to the absolute location under the directory, which directly reaches the target location. It is the real path of the file or directory on the home page on the hard disk, usually from the drive letter; it can specify the complete URL address.

Example:

<h2>使用完整的URL文件路径</ h2>  
<img src ="https://img.php.cn/upload/article/000/000/024/5c18b67545a8c13What are the types of HTML file paths?"  alt="image"    style="max-width:90%">  
<img src ="D:/demo/img/1.jpg"  alt="image"    style="max-width:90%">
Copy after login

Rendering:

What are the types of HTML file paths?

##Relative file pathThe relative file path refers to the path relationship with other files (or folders) caused by the path of this file. It can specify files related to the current page; using relative file paths can bring a lot of convenience.

Here are some examples of relative file paths:

Example 1: How to point to the 1.jpg file located in the same folder as the HTML file, such as:

What are the types of HTML file paths?You can reference the path

<img src ="1.jpg"  alt="image"    style="max-width:90%">
Copy after login

Example 2: How to point to the 1.jpg file located in the img folder of the current directory, Example:

What are the types of HTML file paths?You can quote the path like this:

<img src ="img/1.jpg"  alt="image"    style="max-width:90%">
Copy after login

Example 3: When the 1.html file and the 1.jpg file are in two folders in the same directory, example:

What are the types of HTML file paths?You can reference the path like this:

<img src ="../img/1.jpg"  alt="image"    style="max-width:90%">
Copy after login

The effect achieved by these three examples is the same. The renderings are as follows:

What are the types of HTML file paths?Summary : The above is the entire content of this article. I hope it will be helpful to everyone's study.

The above is the detailed content of What are the types of HTML file paths?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template