Good programmers to share pictures html relative path absolute path to change

Good programmers to share pictures html relative path absolute path to change, to understand the relative path into an absolute path must be modified to know the basic concepts of the path.

html the path : refers to the storage location of the file, using a file path can be referenced in the Web page, complete: insert images, video and other functions . Representation in the html path use in two ways: a relative path, an absolute path.

1, the relative path :

html in the relative path concept is : refers to the current html page referenced file relative to  the current html page file paths in html web page development process in the use of this method to reference content we want to use.

There are many relative path used methods, these methods identified meaning representation is also not the same. So then we look at how to use.

./: the directory where the file on behalf of the ( usually can be omitted)

../: represents the file where the parent directory ( ie the parent directory )

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

/: Root directory where the file on behalf of

Such as: <IMG the src = 'images / 1.jpg ' /> represents 1.jpg images folder in the file path where the html code files in a folder.

<IMG the src = '.. / images / 1.jpg ' /> represents 1.jpg images folder on a file path where the html code files in a folder.

2, absolute address:

It is directly to locate the address of the file location on the disk . Similar to our content specified by a letter of my computer to find the way you want, or directly with protocol, domain names,

3, how the picture html absolute path to a relative path

Html you can use them to provide us with the <base /> tag to complete. Reference sets the default address or a default target <base> tag for all paths on the page. Typically, the browser will get from the current URL of the document to the appropriate elements to fill out a reference path relative.

First <base /> tag is a single tag, while all browsers support <base /> This is a label on the label so we do not consider compatibility. While using the <base /> tag must be taken when the <base /> tag must be placed into the html page <head> </ head> tag which, at the same time each html page which can have at most a <base /> tag its role is obvious. It is that all paths used to the html page references to specify a default address or a default target, marking a setting page is referenced path.

We have just mentioned a common path in the form of relative and absolute paths in html in front, then the use of the <base /> tag at this time to specify the target, then our customers use the client browser will put the content analysis become html relative path referenced in all large, including both <a> </a> hyperlink tag, <img /> image tag, <link> css references tag, <form> </ form> tag form in the address. In other words, the browser will automatically resolve when coupled with the previously cited path <base /> above address binding, while at this time the relative path of the page will also be converted into an absolute path.

Using the syntax:

<head>

<Base href = "target path" />

</head>


Guess you like

Origin blog.51cto.com/14256902/2420800