Home  >  Article  >  Web Front-end  >  How to write relative path in html5

How to write relative path in html5

WBOY
WBOYOriginal
2022-03-21 14:55:532540browse

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.

How to write relative path in html5

The operating environment of this tutorial: Windows 10 system, HTML5 version, Dell G3 computer.

How to write relative paths in html5

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:

<a href = "index.html">这是超连接</a>

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:

<a href = "../index.html">这是超连接</a>

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:

<a href = "../wowstory/index.html">index.html</a>

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:

<a href = "html/index.html">这是超连接</a>

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!

Statement:
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