id选择器

阅读: 3829    发布时间: 2018-01-11 15:37:48

使用"#"加元素的id值作为元素选择器,如下所示:

  • #test1 设置html中id值为test1的元素的样式

  • html中id是唯一的,不应该重复


#test1{
    width: 300px;
    height: 100px;
    background-color: red;
}

#test12{
    width: 300px;
    height: 100px;
    background-color: blue;
}

<div id="test1">

</div>


<div id="test12">

</div>


尝试一下》

-END-