zoukankan      html  css  js  c++  java
  • HTML有2种路径的写法:绝对路径和相对路径

    HTML有2种路径的写法:绝对路径和相对路径

    版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/l18848956739/article/details/53411241

    HTML相对路径(Relative Path)
    同一个目录的文件引用
    如果源文件和引用文件在同一个目录里,直接写引用文件名即可。

    我们现在建一个源文件info.html,在info.html里要引用index.html文件作为超链接。

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/sites/blabla/index.html
    在info.html加入index.html超链接的代码应该这样写:

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

    如何表示上级目录
    ../表示源文件所在目录的上一级目录,../../表示源文件所在目录的上上级目录,以此类推。

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/sites/index.html
    在info.html加入index.html超链接的代码应该这样写:

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

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/index.html
    在info.html加入index.html超链接的代码应该这样写:

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

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/sites/wowstory/index.html
    在info.html加入index.html超链接的代码应该这样写:

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

     
    如何表示下级目录
    引用下级目录的文件,直接写下级目录文件的路径即可。

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/sites/blabla/html/index.html
    在info.html加入index.html超链接的代码应该这样写:

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

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/sites/blabla/html/tutorials/index.html

  • 相关阅读:
    CF101B Buses
    CF1C Ancient Berland Circus
    学习笔记 莫比乌斯反演简单整理
    P3768 简单的数学题
    P2508 [HAOI2008]圆上的整点
    CF19E Fairy
    P1295 [TJOI2011]书架
    CF1148B Born This Way
    CF13E Holes
    CF1148C Crazy Diamond
  • 原文地址:https://www.cnblogs.com/bwdblogs/p/11101288.html
Copyright © 2011-2022 走看看