Http://www.jb51.net/web/14536.html
HTML beginners often encounter such a problem, how to correctly reference a file. For example, how do you refer to another HTML page as a hyperlink (hyperlink) in an HTML page? How to insert a picture in a Web page
If you use the wrong file path when referencing a file (such as adding a hyperlink, or inserting a picture, etc.), it will invalidate the reference (the linked file cannot be browsed, 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 references in 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.html to refer to the index.html file as a hyperlink.
Suppose the info.html path is: c:\Inetpub\wwwroot\sites\blabla\info.html
Suppose the index.html path is: c:\Inetpub\wwwroot\sites\blabla\index.html
The code that joins the index.html hyperlink in info.html should be written like this:
<a href = "index.html" >index.html</a>
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, and so on.
Suppose the info.html path is: c:\Inetpub\wwwroot\sites\blabla\info.html
Suppose the index.html path is: c:\Inetpub\wwwroot\sites\index.html
The code that joins the index.html hyperlink in info.html should be written like this:
<a href = ". /index.html ">index.html</a>
Suppose the info.html path is: c:\Inetpub\wwwroot\sites\blabla\info.html
Suppose the index.html path is: c:\Inetpub\wwwroot\index.html
The code that joins the index.html hyperlink in info.html should be written like this:
<a href = ". /.. /index.html ">index.html</a>
Suppose the info.html path is: c:\Inetpub\wwwroot\sites\blabla\info.html
Suppose the index.html path is: c:\Inetpub\wwwroot\sites\wowstory\index.html
The code that joins the index.html hyperlink in info.html should be written like this:
<a href = ". /wowstory/index.html ">index.html</a>
How to represent a subordinate directory
Refer to the Subordinate directory file, directly write the path of the subordinate directory file.
Suppose the info.html path is: c:\Inetpub\wwwroot\sites\blabla\info.html
Suppose the index.html path is: c:\Inetpub\wwwroot\sites\blabla\html\index.html
The code that joins the index.html hyperlink in info.html should be written like this:
<a href = "html/index.html" >index.html</a>
Suppose the info.html path is: c:\Inetpub\wwwroot\sites\blabla\info.html
Suppose the index.html path is: c:\Inetpub\wwwroot\sites\blabla\html\tutorials\index.html
The code that joins the index.html hyperlink in info.html should be written like this:
<a href = "html/tutorials/index.html" >index.html</a>
HTML absolute Path (Absolute path)
The HTML absolute Path (absolute path) refers to the full path of the file with the domain name.
Suppose you register the domain name Www.jb51.net, and apply for a virtual host, your virtual hosting provider to you a directory, such as WWW, this www is the root directory of your site.
Suppose you have a file index.html in the WWW root directory, the absolute path to this file is: http://www.jb51.net/index.html.
Suppose you build a directory under the WWW root called html_tutorials, and then drop a file in the directory index.html, the absolute path to this file is http://www.jb51.net/html_tutorials/index.html.
HTML relative path and absolute path Difference analysis (RPM)