XHTML relative path vs. absolute path

Source: Internet
Author: User

The file path file path is the location of the file in the computer (server), and there are two ways to represent the file path: relative path and absolute path.     Path identification: Identifies the symbol description/path identification.     Current directory: Previous level directory "." and ".." Often used in conjunction with "/" to represent each path hierarchy: path description./current path, can omit/site root, for absolute path. /previous level directory, reusable, such as: /.. /, indicates that the relative path to the upper-level directory (Relative path) refers to the path to the other file (or folder) that is caused by the path to which the file resides. Using relative paths can give us a lot of convenience, and in most cases we use relative paths. Examples of relative paths:<imgsrc= "Images/flower_1.jpg"alt= "Flower" />This is an example of an IMG tag using a relative path to identify the source of the image in our example home page index.html. In this example, the index.html is stored in the E:/HMTL, and the image position is e:/html/images/flower_1.jpg. The path to the image relative to Index.html is images/flower_1.jpg. The following wording works the same way:<imgsrc= "./images/flower_1.jpg"alt= "Flower" />In other words, usually for the current path, you can use the omitted notation, the browser defaults to the current path. If there is a 1.html in the index.html directory, do a link from index.html to 1.html, using a relative path:<ahref= "1.html">1.html from index.html link to current directory</a>if 1.html is in the E:/hmtl/test directory, to make a link from 1.html to index.html and use the picture in the picture directory, use the relative path:<ahref=".. /index.html ">index.html from the 1.html link to the previous level directory</a><P>Specify Picture:</P><imgsrc=".. /images/flower_1.jpg "alt= "Flower" />Absolute path (Absolute path) absolute path generally refers to the path with a URL, non-site resources must use absolute path. If this site refers to the thinkphp.cn image link<ahref= "http://www.thinkphp.cn/"Target= "_blank"><imgsrc= "Http://www.thinkphp.cn/logo88X31.gif" /></a>in this example, the absolute path is used for the properties in the hyperlink tag and the image tag. Web site root site root directory with "/", is a special absolute path, it represents the first level of the website (this site). Examples of using absolute paths:<imgsrc= "/images/flower_1.jpg"alt= "Flower" />is equivalent to:<imgsrc= "Http://www.5idev.com/images/flower_1.jpg"alt= "Flower" />the advantage of using the root path is that it is more intuitive to calculate from the root, and the disadvantage is that if the content hierarchy changes, even if the changes in the same class, you need to change the directory notation. 

XHTML relative path vs. absolute path

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.