Lesson: HTML5 and CSS
Use a CSS Class to Style an Element
Classes are reusable styles that can be added to HTML elements.
Here's an example CSS class declaration:
You can see that we've created a CSS class called
blue-text within the
You can apply a class to an HTML element like this:
Note that in your CSS
style element, classes should start with a period. In your HTML elements' class declarations, classes shouldn't start with a period.
style element, change the
h2 selector to
.red-text and update the color's value from
h2 element the
class attribute with a value of