RSS
 

The “Cascade” Effect in “Cascading Style Sheets”

05 Jul

Of course there are valid reasons for inline CSS style declarations…that’s why we have them.

Are they misused? Of course.

HTML emails need to be constructed with inline styles…for those who have never tried….but alas, that is not why we have ‘em.

We have them to override those “special one-off” cases that do not require a global definition.

Use the “DRY Principle — Don’t Repeat Yourself”

  1. If you need an inline style, use it.
  2. If you re-use it on that page only, put it in the local stylesheet.
  3. If you use it on multiple pages, refactor it into your global css file.

There was no mention of “specificity” — which may be considered part of the cascade.

/* generalized style -- less specific */
ul { background-color: green; font-weight: bold; }

/* overrides more general styles -- but also inherits */
ul#nav.special { background-color: red; }
VN:F [1.9.3_1094]
Rating: 7.0/10 (1 vote cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)
The "Cascade" Effect in "Cascading Style Sheets", 7.0 out of 10 based on 1 rating
Retweet
 
Comments Off

Posted in UI Design

 

Comments are closed.