CSS的三种定义中类选择符、ID选择符和默认标签选择符的区别
1、类选择符用“.”
多个元素可公用一个class:
在<head></head>中定义如下代码
<head runat="server">
<title></title>
<style type="text/css" >
.class1
{
color:#ff0000;
background:blue;
}
</style>
</head>再在div块中使用
<div class="class1"> 江西省</div>
效果截图:
2、ID选择符用“#”
页面上的元素的ID是唯一的,所以一个“#”定义的样式对应一个元素
在<head></head>中定义如下代码
<style type="text/css">
#div1
{
font-size:xx-large;
}
</style>再在div1中使用
id="div1" > 高安市 </div>
注意:两个style可以合并公用一组<style type="text/css"></style>,定义ID选择符就要在ID名称前加“#”
3、标签选择符
在<head></head>中定义如下代码
<style type="text/css" >
.class1
{
color:#ff0000;
background:blue;
}
div{
font-weight:bold;
}
</style>再在body写如下
<div>CHINA</div>
4、群标签选择符:多个标签公用一个格式
div p{
font-weight:bold
}原文:http://1433189426.blog.51cto.com/8055494/1381469