CSS3 Selectors: Class selectors

This entry is part 5 of 40 in the series CSS3 Selectors

We can apply a class to a particular html element using <span> tag.

If there are other html elements with similar class, they will be affected too.

<!DOCTYPE html>
<html>
<head lang='en'>
    <meta charset='UTF-8'>
    <title>Codecrawl.com</title>
    <style>
        .city {
            font-family: sans-serif;
            color: purple;
            font-weight: bold;
        }
    </style>
</head>
<body>

<h2>Taylor Swift</h2>

<p> Taylor Swift moved to <span class='city'>Nashville</span>, Tennessee, at the age of 14 to pursue a career in country
    music.</p>

</body>
</html>

Series Navigation<< CSS3 Selectors: Universal selector *
CSS3 Selectors: ID selectors >>