Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change the absolute path of a picture to a relative path by html

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to change the absolute path of a picture into a relative path by html". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Good programmers share html pictures to change absolute path to relative path. To understand how to change relative path to absolute path, you must know the basic concept of path.

Path in html: refers to the location where the file is stored, and the path can be used to reference the file in the web page to complete: insert image, video and other functions. Indicates that paths are used in two ways in html: relative paths and absolute paths.

1. Relative path:

The concept of relative path in html refers to the path of the file referenced by the current html page relative to the current html page file. This method is often used to reference the content we want to use in the process of html page development.

Relative paths are used in a variety of ways, and these methods represent different meanings. So let's take a look at how it is used.

. /: represents the directory where the file is located (usually you can omit it)

.. /: represents the parent directory where the file is located (that is, the previous directory)

.. /. /: represents the parent directory of the parent directory where the file is located (that is, the directory one level up)

/: represents the root directory where the file is located

Such as:

Represents the 1.jpg file under the images folder under the path of the html file where this code is located.

Represents the 1.jpg file under the images folder one level above the path of the html file where this code is located.

2. Absolute address:

Is to locate the address of the file directly from the location of the disk. Similar to the way we look for the specified content through my computer, or directly with the agreement and domain name.

3. How to change the absolute path of html pictures to relative path.

You can do this using the tags provided to us in html. The tag sets the default address or default destination for references to all paths on the page. Typically, the browser will get the corresponding element from the URL of the current document to fill in the relative reference path.

First of all, the tag is a single tag, and all browsers support this tag, so you don't have to think about compatibility. At the same time, when using tags, we must pay attention to tags, must be placed in the tags of html pages, while each html page can only have at most one tag, its role is also very obvious. It is used to specify the default address or default destination for all path references on the html page. It is a tag that sets the reference path in a web page.

We have just mentioned that the common path forms in html are relative path and absolute path, so if the tag is used to specify the target at this time, then the client browser used by our users will parse the content into all relative paths with large references in the current html, including hyperlink tags,

The address in the picture tag, css reference tag, and form tag. In other words, when parsing, the browser will automatically add the binding address in front of the referenced path, and at this time, the relative path in the page will be converted to the absolute path.

Use syntax:

This is the end of the content of "how to change the absolute path of a picture to a relative path by html". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report