CSS 类选择器

类选择器使用一个点号显示

.center{text-algin:center;}

拥有center样式的html元素均为居中。

例如

<h2 class="center">
hello world
</h1>

<p class="center">
This paragraph will also be center-aligned.
</p>

注意:类名的第一个字符串不能使用数字,它无法在Mozilla 或 Firefox 中起作用。

类选择器和ID选择器一样,也可以被用作派生选择器

.find p{
    color:blue;
    backgroup:while;
}

以上代码字体显示蓝色,背景显示白色(名为find的元素可能为一个表格或者一个div)
元素也可能基于它们的类而被选择

td.find{
    color:blue;
    backgroup:while;
}

上边的列子是表格的td为蓝色字体和背景色为白色;
html中的代理为

<td class="find">我是蓝色的字</td>

有find类的td则表示受影响,如果没有find类则不受影响。