How to create a group of css multiple classes same style?
Dung Do Tien
Aug 01 2021
155
Hi Guys, I just began to study CSS(Cascading Style Sheets). I have a problem, I have three classes as below:
h1{
color: #333;
font-family: 'arial';
}
h2{
color: #333;
font-family: 'arial';
}
p{
color: #333;
font-family: 'arial';
}
You can see they are in the same style. I feel they're so long and redundant of code. How to create a group css multiple classes with the same style?
Thanks for any suggestions.
Have 2 answer(s) found.
-
S0
Sáng Cao Aug 01 2021
h1, h2, p{ color: #333; font-family: 'arial'; }
It's what are you looking for!!
-
Đ0
Đặng Thanh Tuấn Aug 01 2021
You can use a comma
,
to help define many classes, ids have the same style. For example:h1, h2, p{ color: #333; font-family: 'arial'; }
Or
a, #id, p.heading{ color: #333; font-family: 'arial'; }
* Type maximum 2000 characters.
* All comments have to wait approved before display.
* Please polite comment and respect questions and answers of others.