


In-depth understanding of HTML relative path (Relative Path) and absolute path (Absolute Path)_HTML/Xhtml_Web page production
I have been engaged in Java web development for more than a year. It is inevitable to write HTML or JSP pages. The power of web applications lies in its hyperlinks (Hyper Link). For example, in page a, save the link address pointing to page b ( That is, URI), but the problem lies precisely here, how to correctly reference a file. For example, how to reference another HTML web page as a hyperlink in an HTML web page? How to insert an image into a web page? ......
In addition, relative paths are also very popular in struts, and it is easy to get confused if you are not careful.
If you use the wrong file path when referencing a file (such as adding a hyperlink, or inserting a picture, etc.), the reference will become invalid (the linked file cannot be browsed, or the inserted picture cannot be displayed, etc.).
In order to avoid these errors, cite the documents correctly and write down the differences and usages so that you can check them in the future.
HTML has two ways of writing paths: relative paths and absolute paths
HTML relative path (relative path)
File references in the same directory
If the source file and the reference file are in the same directory, just write the name of the reference file directly.
We now create a source file info.HTML, and reference the index.HTML file as a hyperlink in info.HTML.
Assume the info.HTML path is: d:tomcatwebappshelloblablainfo.HTML
Assume the index.HTML path is: d:tomcatwebappshelloblablaindex.HTML
The code to add the index.HTML hyperlink to info.HTML should look like this Write:
How to represent the upper-level directory
../ represents the upper-level directory of the directory where the source file is located, .. /../ represents the upper-level directory of the directory where the source file is located, and so on.
Assume the info.HTML path is: d:tomcatwebappshelloblablainfo.HTML
Assume the index.HTML path is: d:tomcatwebappshelloindex.HTML
The code to add the index.HTML hyperlink to info.HTML should look like this Write:
Assume the info.HTML path is: d:tomcatwebappshelloblablawowstoryinfo.HTML
Assume the index.HTML path is: d:tomcatwebappshelloindex. HTML
The code to add index.HTML hyperlink to info.HTML should be written like this:
Assume the info.HTML path It is: d:tomcatwebappshelloblablainfo.HTML
Assume the index.HTML path is: d:tomcatwebappshellowowstoryindex.HTML
The code to add the index.HTML hyperlink to info.HTML should be written like this:
How to represent the lower-level directory
refers to the file in the lower-level directory, just write the path of the file in the lower-level directory directly.
Assume the info.HTML path is: d:tomcatwebappshelloblablainfo.HTML
Assume the index.HTML path is: d:tomcatwebappshelloblablaHTMLindex.HTML
The code to add the index.HTML hyperlink to info.HTML should look like this Write:
Assume the info.HTML path is: d:tomcatwebappshelloblablainfo.HTML
Assume the index.HTML path is: d:tomcatwebappshelloblablaHTMLtutorialsindex.HTML
The code to add index.HTML hyperlink to info.HTML should be written like this:
HTML absolute path (absolute path)
HTML absolute path (absolute path) refers to the full path of a file with a domain name.
Suppose you register the domain name www.jb51.net and apply for a virtual host. The virtual host provider will give you a directory, such as www. This www is the root directory of the website.
Assume that a file index.HTML is placed in the www root directory. The absolute path of this file is: http://www.jb51.net/index.html.
Assume that in the www root directory Create a directory called HTML_tutorials under the directory, and then place a file index.HTML in the directory. The absolute path of this file is http://www.jb51.net/article/32759.htm.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



From absolute path to relative path: Linux path usage tips In Linux systems, path is an important concept that we often encounter when operating files and directories. In the use of paths, absolute paths and relative paths are two common representation methods. This article will delve into how to flexibly use paths in Linux systems, especially the technique of converting from absolute paths to relative paths, and demonstrate it through specific code examples. What are absolute paths and relative paths? First, we need to clarify the absolute path and relative path

Visual Studio Code is a mini version of the Visual Studio IDE, it is lightweight, can use a large number of extensions, supports all languages and more. When it comes to extensions, you should know the best Visual Studio Code extensions to increase your productivity. For Visual Studio IDE users, we've got a guide listing some of the best extensions for Visual Studio. In this guide, we'll provide you with a bunch of Visual Studio Code extensions that will help you be more efficient and productive. Let's jump right into it. What is the best Visual Studio

Understand the difference between Linux absolute paths and relative paths. In Linux systems, the file system is organized in a tree structure, and each file or directory has a unique path to locate their location in the file system. When using a Linux system, the concepts of absolute paths and relative paths are often involved. This article will explain the difference between absolute paths and relative paths in detail, and use code examples to illustrate their application. An absolute path is a complete path starting from the root directory describing the location of a file or directory. Root directory in Linux

Master path representation in Linux systems: absolute paths and relative paths. In Linux systems, path representation is very important basic knowledge, especially for developers and system administrators. Path representation is mainly divided into two types: absolute path and relative path. This article will illustrate the difference and usage of these two path representations through specific code examples. 1. Absolute path An absolute path is a complete path starting from the root directory, indicating the location of a file or directory in the entire file system. Absolute paths start with a slash "/", for example: /h

In the web front-end, the relative path refers to the path relationship with other files (or folders) caused by the path of the current file. It is the target file location relative to the current file; simply speaking, it uses the current file as the reference point. , to determine the paths of different files. Relative paths generally start with "./" or "../". Benefits: When the entire project is moved, the relative relationship between files within the project does not change, and the previously set paths are still accurate and do not need to be modified.

How to correctly use Linux’s absolute paths and relative paths. As a commonly used operating system, Linux’s file system path is an integral part of user operations. In Linux systems, there are two commonly used path representation methods, namely absolute paths and relative paths. Correct use of absolute paths and relative paths is the key to improving work efficiency. The following will introduce how to correctly use absolute paths and relative paths in Linux with specific code examples. 1. Absolute path The absolute path refers to starting from the root directory until the file

PHP function introduction—realpath(): returns the absolute path. When developing PHP programs, we often encounter file path problems. Especially when we need to read, write or reference other files, it is very important to ensure that the obtained path is accurate. PHP provides a very practical function to solve this problem, which is the realpath() function. The function of realpath() function is to convert the given relative path to an absolute path and return the result. This means that regardless of the execution of the current code

Application scenarios of absolute paths and relative paths in Linux In Linux systems, there are two common forms of path representation for files and directories, namely absolute paths and relative paths. In practical applications, choosing an appropriate path representation method can improve work efficiency and simplify operating procedures according to different needs and scenarios. 1. Absolute path An absolute path is a path expression that describes the location of a file or directory starting from the root directory. In the Linux system, the root directory is represented by "/", and the directories below it are subdirectories in turn, until they finally point to
