A Simple Tip for Css Selector

Posted by Yan on March 5, 2015

As I am not a professional UI developer, I always learn and get confused about the CSS selector.

In this post, I just want to remember myself that for a HTML class, we can assign a number of class names. For example,

<!DOCTYPE html>
<html>
<head>
    <style>
        .header{
            color: red;
        }
        .small-header{
            font-size: 0.5em;
        }
    </style>

</head>
<body>
<div class="header small-header">
    <h3>I am a header</h3>
</div>

<div class="header">
    <h3>I am a normal header</h3>
</div>

</body>
</html>

In this html, a class can have two class which is header and small-header. If you run the page, it will look like:

htmlcss