Home>Article>Web Front-end> How to write relative path in html5
html5 relative path writing method: 1. Use "file name" to represent the same level path file; 2. Use "./file name" to represent the superior directory file; 3. Use "../file name" Represents upper-level files; 4. Use "same-level directory name/file name" to represent lower-level directory files.
The operating environment of this tutorial: Windows 10 system, HTML5 version, Dell G3 computer.
Purpose: Specify the path relationship with other files (or folders) caused by the path where this file is located
If the source file If it is in the same directory as the referenced file, just write the name of the referenced file directly. At this time, the way to reference the file is to use a relative path.
The following creates two HTML documents info.html and index.html as examples. The requirements are to add the index.html hyperlink to info.html.
eg1: Simple application of relative paths
Assumption: info.html path is: c:/Inetpub/wwwroot/sites/blabla/info.html
The path to index.html is: c:/Inetpub/wwwroot/sites/blabla/index.html
Writing:
这是超连接
eg2: How to represent the upper-level directory
../ represents the upper-level directory of the directory where the source file is located, http://www.cnblogs.com/ represents the upper-level directory of the directory where the source file is located, and so on.
Assumption: The path of info.html is: c:/Inetpub/wwwroot/sites/blabla/info.html
The path of index.html is: c:/Inetpub/wwwroot/sites/index .html
Writing method:
这是超连接
eg3: How to represent the upper-level directory
Assumption: info.html path is: c:/Inetpub/wwwroot /sites/blabla/info.html
The index.html path is: c:/Inetpub/wwwroot/sites/wowstory/index.html
Writing:
index.html
eg3: How to represent the lower-level directory
To reference files in the lower-level directory, just write the path of the file in the lower-level directory directly.
Assumption: The path of info.html is: c:/Inetpub/wwwroot/sites/blabla/info.html
The path of index.html is: c:/Inetpub/wwwroot/sites/blabla /html/index.html
Writing:
这是超连接
Recommended tutorial: "html video tutorial"
The above is the detailed content of How to write relative path in html5. For more information, please follow other related articles on the PHP Chinese website!