CSS Tip: Avoid applying positioning at element level

Here’s a little CSS tip: Don’t apply positioning rules (including alignment, margins, floats, etc) to a base element, for there will surely come a day when you say, “But I don’t want <label> elements to float left on this page!” Instead, use a rule based on a class or id. You may find that every single instance of said element now has the same class attribute, but it will make life much easier in the long run.

The Bad

label {
position: absolute;
}

The Good:

.label_abs {
position: absolute;
}

* This post was originally published on January 8, 2007 at http://www.csb7.com/blogs/whyblogwhy/2007/01/08/css_tip_avoid_applying_positioning_at_el

I am patient with stupidity but not with those who are proud of it.

— Edith Sitwell