CSS (Cascading Style Sheets) define a webpage element’s appearance by hooking into the attributes that are applied to that element. These attributes can be either an ID or a class and, like all attributes, they must add helpful information to the elements that they are assigned to.
An element is usually only assigned one class. The corresponding CSS for that particular class defines the appearance properties for that class.
However, we can also assign multiple classes to the same element in CSS. In some cases, assigning multiple classes makes page styling easier and much more flexible.
To assign multiple classes to an element, separate each class with a space within the element’s class attribute.
<p> Some text... </p>
The first div gets the properties of class1
, the second div gets those of class2
, while the third gets the properties of both class1
and class2
.
Free Resources