HTML Classes
The HTML class attribute is used to specify a class for an HTML element.
The HTML class attribute is used to specify a class for an HTML element. Multiple HTML elements can share the same class.
Using the class Attribute
The class attribute is often used to point to a class name in a style sheet. It can also be used by JavaScript to access and manipulate elements with the specific class name.
Preview
The Syntax For Class
To create a class; write a period (.) character, followed by a class name. Then, define the CSS properties within curly braces {}.
Multiple Classes
HTML elements can belong to more than one class. To define multiple classes, separate the class names with a space.
Preview
Classes in JavaScript
JavaScript can access elements with a specific class name using document.getElementsByClassName().