Posts tagged with “”

Labels. They're Not Just for Forms Anymore.

Think semantically, not dogmatically. Labels can be used to describe data as well as form fields. I can’t tell you how often I’ve seen something like this:

<div id="image-info">
   <span class="label">Name:</span><span>myimage.jpg</span>
   <span class="label">Size:</span><span>5KB</span>
   <span class="label">MIME Type:</span><span>image/jpg</span>

The obvious red flag here is that the name of the class is also the name of a tag, but a lot of examples aren’t quite so obvious. Nonetheless, when labeling data, use the label tag to do it. I’ve never seen any indication that it’s incorrect in any way.

Techniques for Clean Markup

It’s exceedingly rare that I read an article on code techniques and agree with absolutely everything that’s being espoused, but this article by Chris Coyier for Smashing Magazine is just that. In my opinion, this is a must read for all web developers that have to work in and around X/HTML code. My personal favorite: Eliminate unnecessary divs.

Sometime during the learning stages of Web design, people learn how to wrap elements in a div so that they can target them with CSS and apply styling. This leads to a proliferation of the div element and to their being used far too liberally in unnecessary places.

Oh yeah. And the example provided could not be more illustrative.

The others are spot on, as well, but this is my favorite because it’s less obvious and the single biggest source of code bloat, in my experience.