If you are referencing a file (such as adding a hyperlink, or inserting a picture , etc.), the wrong file path is used.
Will invalidate the reference (the linked file cannot be browsed, or the inserted picture cannot be displayed, etc.).
To avoid these errors and to properly reference the file, we need to learn the HTML path.
HTML has 2 ways of writing: relative and absolute paths.
HTML relative path (Relative path) file reference for the same directory
If the source and reference files are in the same directory, write the reference file name directly.
We are now building a source file info.HTML, in info.HTMLTo quote index.HTMLFile as a hyperlink.
Suppose info.HTMLThe path is: C:\Inetpub\wwwroot\sites\blabla\info.HTML
Assume index.HTMLThe path is: C:\Inetpub\wwwroot\sites\blabla\index.HTML
In info.HTMLJoin index.HTMLof hyperlinksCodeIt should be written like this:
- <a href = "index. HTML">index. HTML</a>
Copy Code
How to represent a parent directory
.. /indicates the directory where the source file is located, at the top level of the directory. /.. /represents the upper parent directory of the directory where the source file resides, in such
Push.
Suppose info. The HTML path is: C:\Inetpub\wwwroot\sites\blabla\info. HTML
Assume index. The HTML path is: C:\Inetpub\wwwroot\sites\index. HTML
In info. HTML joins index. The code for the HTML hyperlink should read like this:
- <a href = ". /index. HTML">index. HTML</a>
Copy Code
Suppose info. The HTML path is: C:\Inetpub\wwwroot\sites\blabla\info. HTML
Assume index. The HTML path is: C:\Inetpub\wwwroot\index. HTML
In info. HTML joins index. The code for the HTML hyperlink should read like this:
- <a href = ". /.. /index. HTML">index. HTML</a>
Copy Code
Suppose info. The HTML path is: C:\Inetpub\wwwroot\sites\blabla\info. HTML
Assume index. The HTML path is: C:\Inetpub\wwwroot\sites\wowstory\index. HTML
In info. HTML joins index. The code for the HTML hyperlink should read like this:
- <a href = ". /wowstory/index. HTML">index. HTML</a>
Copy Code
How to represent a subordinate directory
Refer to the Subordinate directory file, directly write the path of the subordinate directory file.
Suppose info. The HTML path is: C:\Inetpub\wwwroot\sites\blabla\info. HTML
Assume index. The HTML path is: c:\Inetpub\wwwroot\sites\blabla\html\index. HTML
In info. HTML joins index. The code for the HTML hyperlink should read like this:
- <a href = "html/index. HTML">index. HTML</a>
Copy Code
Suppose info. The HTML path is: C:\Inetpub\wwwroot\sites\blabla\info. HTML
Assume index. The HTML path is:
C:\Inetpub\wwwroot\sites\blabla\HTML\tutorials\index. HTML
In info. HTML joins index. The code for the HTML hyperlink should read like this:
- <a href = "html/tutorials/index. HTML">index. HTML</a>
Copy Code
HTML absolute path (Absolute path)
HTML absolute path (Absolute path ) refers to the full path of the file with the domain name.
Assume that you have registered the domain name xinran001.com , and you have applied for a virtual host, your virtual hosting provider gives you a directory, such as WWW, This www is the root directory of your .
Assume that you have placed a file at the WWW root index. html , the absolute path to this file is:
http://www.xinran001.com/index. , the absolute path to this file is
http://www.xinran001.com/bbs/index.php .