<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>selector-class.html</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="this is my page">
<meta name="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="styles.css">-->
<!-- CSS 类选择器:在 CSS 中,类选择器以一个点号显示
类选择器允许以一种独立于文档元素的方式来指定样式。类选择器可以单独使用,也可以与其他元素结合使用。
只有适当地标记文档后,才能使用这些选择器,所以使用这两种选择器通常需要先做一些构想和计划。
要应用样式而不考虑具体设计的元素,最常用的方法就是使用类选择器。
为了将类选择器的样式与元素关联,必须将 class 指定为一个适当的值。
和 id 一样,class 也可被用作派生选择器:
.center {text-align: center}
td.fancy {
color: #f60;
background: #666;
}
.fancy td {
color: #f60;
background: #666;
}
-->
<style type="text/css">
.important {font-weight:bold;}
.warning {font-style:italic;}
.important.warning {background:silver;}
</style>
</head>
<body>
<p class="important">This paragraph is very important.</p>
<p class="warning">This is a warning.</p>
<p class="important urgent warning">This paragraph is a very important warning.</p>
<p>This is a paragraph.</p>
<p>...</p>
</body>
</html>