1. css作用
将文档与格式分离 ; 更好地控制网页布局; 网页体积更小
css通过规则控制页面,规则分选择和说明两部分。选择可以是任何html标签,说明包括属性和属性值两部分,说明被符号“{ }”包含。
2. css使用
2.1 植入式
直接将样式表添加在网页的<body>之前
<style type="text/css">
<--
样式规则
-->
2.2 链接式
将外部css文件链接进文档
<LINK rel=stylesheet url="mycss.css" type="text/css">
2.3 输入式
与链接式相似,但可以与其他方法同用
<style type="text/css">
<--
@import url("mycss.css");
其他样式规则
-->
2.4 行内式
<p style="font-family:">
<--
@import url("mycss.css");
其他样式规则
-->
2.4 行内式
<p style="font-family:">
3. css技巧
分类:将一个选择分为不同类别,可对不同类别实施不同的控制。如:
p.first {color: green}
p.second {color: red}
p.third {color: gray}
<p class = first>this is the first class</p>
或直接用类别名:.first {color: green} 这样所有此类别的内容颜色都为绿色,而不止局限在<p>标签内
<--
@import url("mycss.css");
其他样式规则
-->
2.4 行内式
<p style="font-family:">