CSS Tip: Don’t Duplicate Attributes

In your CSS, you specify that your #header, #footer and #sidebar elements should be baby blue. A week later, your picky designer asks that they be changed to lilac. Of course, you can change the color for all three elements, but, as the DRY gods will tell you, find/replace is error-prone.

You should only specify colors (and, preferably, most attributes) only once in your stylesheet.

The Wrong(ish) Way:

.header {
color:baby-blue;
font-size:humungo
} .footer {
color:baby-blue;
font-size:tiny;
}

The Right(er) Way:

.header, .footer {
color:baby-blue;
} .header {
font-size:humungo
} .footer {
font-size:tiny;
}

This entry was posted in Angry Development Tips, Design, Technology. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>