I have a standard style where text is typically white and links are typically red. However, in some menus, I would the text and the links to be both white.
I have the following Html:
<div class='mydiv2'>
Some text with some <a href="http://google.com">link</a>
</div>
and the following CSS:
.mydiv2 {
background-color: green;
color: white;
}
.mydiv2 a {
color: white;
}
Is there any way to merge the two above css statements into one?
The JsFiddle is here .
Use this code:
.mydiv2, .mydiv2 a {
background-color: green;
color: white;
}
The comma allows you to have multiple selectors for a CSS statement.
EDIT: As mentioned above in the comments, this feature is documented here: http://www.w3.org/TR/CSS2/selector.html#grouping .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.