Things You'll Need:
- A text editor or an HTML editor
-
Step 1
Classes in CSS are not a bad thing. But often classes get added repeatedly when a descendant selector would do the same thing with much less code added to a page.
-
Step 2
Code with classitisHere's an example of classitis.
-
Step 3
In the CSS there would be one rule for the ID #leftcol and a second rule for the class .smalltext. Two rules are, indeed, needed in the CSS, but this is the wrong approach.
-
Step 4
Clean codeA better solution is a rule for #leftcol and a second rule for the descendent selector #leftcol p. Every paragraph in the "leftcol" div would be styled by the rule and no class attributes would need to be added to the code. With a descendant selector the code would look like this.
-
Step 5
Using a descendant selector such as #leftcol p has the same effect on the appearance of the paragraphs, but less code has to be downloaded by the user, making the page load faster while still looking exactly as you want.










Comments
circalinkdotcom said
on 7/27/2009 Classitis should be inducted into websters dictionary!
taylorcc said
on 5/22/2008 Love it. Looks much cleaner.