March 2018
Beginner to intermediate
514 pages
13h 11m
English
Similar to the ID selector, the class selector allows you to style elements with a given class, regardless of their element type. This means one or more elements and element types can be styled using it and hence it's the most practical one:
<!DOCTYPE html><html><head>#redcolor { color: red;}</head><body><h1 class="redcolor">This is a Heading</h1><p>This is a styled paragraph.</p><p class="redcolor">This is a styled paragraph.</p></body></html>
In the preceding example, both the <h1> and the second <p> class element font color will be red as a result.
Read now
Unlock full access