基础
说明
层叠样式biao修饰HTML,负责网页的表面(页面元素的外观,位置等页面样式,如:颜色,大小等
嵌入CSS样式的方法
行内样式
写在标签的style属性中(不推荐)
<h1 style="xxx: xxx; xxx: xxx;">
中国新闻网
</h1>
内嵌样式
写在style标签中(可以卸载页面任何位置,但通常约定写在head标签中)
<style type="text/css">
选择器 {
样式名: 样式值;
样式名: 样式值;
}
CSS中常见的选择器:
元素选择器
id选择器
class选择器
</style>
CSS选择器(id>类>元素)
①元素选择器--所有同元素名的值
元素名称 {
color: red;
}
h1 {
color: red;
}
<h1> hello css </h1>
②id选择器--id为唯一值
#id属性值 {
color: red;
}
#hid {
color: red;
}
<h1 id="hid">css id</h1>
③类选择器--class为一类值
.class属性值 {
color: red;
}
.cls {
color: red;
}
<h1 class="cls">css class</h1>