This time I will bring you the href attribute of the HTMLa tagSpecify the relative path and absolute path usage, use the href attribute of the HTMLa tag to specify the relative path and absolute path usageNotesWhat are they? The following is a practical case. Let’s take a look.
In actual Web development, insertingimages, including CSS files, etc. all require paths. If the file path is added incorrectly, it will cause the reference to become invalid (unable to Browsing linked files, or inserted pictures cannot be displayed, etc.). Many beginners are confused. Below I will introduce relative paths and absolute paths in detail.
HTML relative path refers to the path relationship with other files (or folders) caused by the path where this file is located.
For example:
文件1.htm的绝对路径是:d:/www/html/1.htm 文件2.htm的绝对路径是:d:/www/html/2.htm 那么:1.htm相对于2.htm的路径就是:1.htm
If you link to the same directory, you only need to enter the name of the document to be linked, for example:
<a href =”1 htm”>网页链接 </a> <img src=”bg.jpg” />
<a href =”html/ next.htm”> <img src=”images/bg.jpg” />
<a href = “../ www/index.htm”>
现在有4个html文件分别是aaa.html bbb.html ccc.html index.html aaa.html的路径为:D:/www/adminwang/html/aaa.html bbb.html的路径为:D:/www/adminwang/ bbb.html ccc.html的路径为:D:/www/ ccc.html index.html的路径为D:/www/ index.html
For example, ccc.html file link The code of index.html is as follows:
<a href="index.html">链接index网页</a>
For example, the code of bbb.
html link to ccc.html is as follows:
<a href="../ccc.html">链接ccc网页</a>
For example, the code for linking aaa.html to ccc.html is as follows:
<a href=”../../ccc.html”>链接ccc网页</a>
For example, ccc.html links to bbb.html The code is as follows:
<a href="adminwang/bbb.html">链接bbb网页</a>
For example, the code for ccc.html to link aaa.html is as follows:
<a href="adminwang/html/aaa.html">链接aaa网页</a>
Provide the file The full path to , including the applicable protocol or drive letter. That is, the real full path of the file or directory on your home page on the hard disk. For example:
http://www.adminwang.com/index.htm d:/ www /html/images/bg.jpg
Detailed explanation of examples of HTML text formatting
Summary of frequently used tags in html
The basics of HTML editing (a must-read for beginners)
The above is the detailed content of The href attribute of the HTMLa tag specifies how to use relative paths and absolute paths. For more information, please follow other related articles on the PHP Chinese website!