CSS 选择器定义颜色 示例代码

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>找找网 - CSS Syntax</title>
    <style>
        /* 类选择器 */
        .zz123_parent {
            color: blue; /* 可继承的属性 */
            font-family: Arial, sans-serif;
        }
        /* ID选择器 */
        #zz123_child {
            color: red !important; /* 使用 !important 提高优先级 */
        }
        /* 元素选择器 */
        p {
            margin: 10px;
        }
    </style>
</head>
<body>
    <div class="zz123_parent">
        <p id="zz123_child">这段文字的颜色应该是红色,因为ID选择器的优先级更高。</p>
        <p>这段文字的颜色应该是蓝色,因为它继承自父元素。</p>
    </div>
</body>
</html>