一、绝对路径
绝对路径是指文件在硬盘上真正存在的路径
- D:JavaJavaWebday01a.jpg
- http://www.baidu.com/b.jpg
二、相对路径
一个文件相对于另外一个文件的位置
分为三种:
** html文件和图片在一个路径下(当层目录),可以直接写文件名称
<img src="a.jpg"/>
** 图片在html的下层目录
在HTML文件中,使用img文件夹下面的a.jpg
<img src="imga.jpg"/>
** 图片在HTML文件的上层目录
<img src="../a.jpg"/>
**如果是上层的上层
../../
** 特殊的一种:相对虚拟目录
例如:<img src="/img/bg.jpg">
在这个例子里,注意在“img”前有一个“/”字符。这个“/”代表的是虚拟目录的根目录. 假设把“E:ook网页布局代码”设为虚拟目录,那么“/img/bg.jpg”的真实路径为“E:ook网页布局代码img g.jpg”;如果把“E:ook网页布局代码第2章”设为虚拟目录,那么“/img/bg.jpg”的真实路径为“E:ook网页 布局代码第2章imgg.jpg”