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>
<head lang='en'>
    <meta charset='UTF-8'>
        .city {
            font-family: sans-serif;
            color: purple;
            font-weight: bold;

<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


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