两种样式表

来源:互联网 发布:选购冰箱知乎 编辑:程序博客网 时间:2024/06/05 14:54

 

外部样式表

采用外部样式表是最好的,它能使创建网页变的简单。将所有样式信息放在一个文件里,然后用一行代码引用它即可。
代码很容易错字,检查办法有firefox – tools – error 控制台 – 点击“警告(warnings)”就可以看到firefox 无法识别的css代码。

    关联外部样式表

<link>标签

html <link rel=”stylesheet” type=”text/css” href=”css/global.css”>XHTML <link rel="stylesheet" type="text/css" href="css/global.css" />

rel-- 表示连接类型 --- styesheet 指的是链接到样式表。
type –- 是让浏览器知道需要哪一种数据,这里是css文件。
href— 指向css文件位置目录。

浏览器为了能快速浏览网页,会在浏览后预留存储图片,外部css文件,这叫高速缓存。但浏览器缓存重复调用会导致网站设计出错,解决办法是让浏览器重新加载链接文件,Ctrl+F5或Ctrl+Shint+R。

 

内部样式表

内部样式表是有多个样式组成,是网页代码的一部分。
在<head>,<stype> 标签之间

<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">h1{color:#06C;}p {color:#33F;}</style></head><body></body></html>

 

 


<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>