Web Design Best Practices, Overdoing your CSS

Over-Doing It

Tagitis

Tagitis is the adding of many useless XHTML tags. This header, for instance, suffers from tagitis:

<h3><em>Header</em></h3>

You don’t need the extra tag. One line of CSS would give the same effect:

h3 {
     font-style: italic;
}

Classitis and Divitis

A common error of beginning CSS coders is to use far too many

div tags and class attributes, like:

<div class="header">
<div class="headerText">
<p class="headerP">
This site uses CSS!
 
</p></div>
</div>

Ninety-nine out of a hundred times these complicated structures are unnecessary. When you start writing CSS you should avoid them, instead of thinking you found the one in hundred exception to the rule. Start with simple XHTML:

<div class="header">
This site uses CSS!
</div>

Use these two CSS selectors:

div.header {
/* styles */
}
div.header p {
/* styles */
}

You’ll find that you can style the entire header by styling these two selectors.

This entry was posted in Web Design Best Practices. Bookmark the permalink. Follow any comments here with the RSS feed for this post. 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> <pre lang="" line="" escaped="">