CSS

一、什么是CSS

CSS是层叠样式表
样式定义了如何显示HTML元素
样式存储在样式表中
外部样式能够极大提高工作效率
外部样式表存储在.css文件中
多个样式可以层叠为一。

二、样式表层叠的优先级

1浏览器缺省
2、外部样式
3、内部样式(存储在head标签中)
4、内联样式(位于HTML元素中)

三、CSS语法规则

CSS语法规则主要由两部分组成:选择器、多条声明语句

四、选择器的分类

CSS选择器主要分为四大类:

组合选择器——之间用“,”隔开
h1,h2,h3,h4,h5,h6 {
  color: green;
}
————————————————————————————————————————————————————————————————————————————————
派生选择器----之间用空格隔开
li strong {
    font-style: italic;
    font-weight: normal;
  }
————————————————————————————————————————————————————————————————————————————————
id选择器----用#代表是id选择器,后面跟着id的名字
<html>
<head>
<style type="text/css">
#intro {font-weight:bold;}
</style>
</head>

<body>
<p id="intro">This is a paragraph of introduction.</p>

<p>This is a paragraph.</p>

<p>This is a paragraph.</p>

<p>This is a paragraph.</p>

<p>...</p>
</body>
</html>
————————————————————————————————————————————————————————————————————————————————
​​​​​​​类选择器----“.”代表使用类选择器,‘.’后面紧接着类名
<html>
<head>
<style type="text/css">
.important {color:red;}
</style>
</head>

<body>
<h1 class="important">This heading is very important.</h1>

<p class="important">This paragraph is very important.</p>

<p>This is a paragraph.</p>

<p>This is a paragraph.</p>

<p>This is a paragraph.</p>

<p>...</p>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值