在CSS中,类选择符在一个半角英文句点(.)之前,而id则在半角英文井号(#)之前。
class的一个例子:
1
#top { background-color: #ccc; padding: 1em }
2

2

id的一个例子:
1
.intro { color: red; font-weight: bold; }
2

2

在HTML中调用CSS的连接用属性id和class的例子如下:
1
<div id="top"> <h1>Chocolate curry</h1> <p class="intro">This is my recipe for making curry purely with chocolate</p> <p class="intro">Mmm mm mmmmm</p> </div>
2

2
