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

  • 相关阅读:
    ‘随意’不是个好词,‘用心’才是
    servlet
    tomcat服务器
    http协议
    jdbc(Java数据库连接)
    dbcp和druid(数据库连接池)
    关于GitHub
    冒泡和递归
    python内置函数
    python四
  • 原文地址:https://www.cnblogs.com/bwdblogs/p/11101288.html
Copyright © 2011-2022 走看看