We can apply multiple CSS classes to a single element by using the class attribute and separating each class with a space.
There are two ways to apply two CSS classes to a single element -
Use class attributes -
1 |
|
Using JavaScript −
Given that there is a p tag with the id 'paragraph', we want to apply these classes -
1 2 3 4 5 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
Save the above code in a file with a .html extension.
Open the file in a web browser.
The above is the detailed content of How to apply two CSS classes to a single element?. For more information, please follow other related articles on the PHP Chinese website!