Wednesday, December 4, 2013

using commas to consolidate CSS styles

This...

.displaynone {
   display: none;
}
.hideInnerDivs div {
   display: none;
}

 
 

...may be consolidated to...

.displaynone, .hideInnerDivs div {
   display: none;
}

 
 

...without issue! In both examples, displaynone hides the immediate thing it styles (and everything inside) while hideInnerDivs does not hide the immediate thing it styles, just the div tags nested within said DOM node. The second effect is a cascading effect. Rock!

No comments:

Post a Comment