Debug CSS

Debug CSS is nothing new. Eric Meyer has been talking about them since the 1940's. Still, not many developers use them when building and testing.

I just added a debug CSS to a site that we're working on. Its purpose is to visually highlights 5 markup problems.

  1. Images with a blank alt attribute value, i.e. alt="". This won't cause validation errors, but a blank alt doesn't help with accessibility either.
  2. Images with a missing alt attribute. A strict doc type and Firefox's HTML Validator extension brings this error to light as well. A debug CSS is even better, highlighting the error right on the page.
  3. Undefined links, i.e. href="". This is common when building a site. The developer knows that something is linked but isn't sure of the URL yet. When testing, instead of manually clicking through all the links, a debug CSS can highlight them.
  4. Links to nothing, i.e. href="#". Identical to the item above, but some developers prefer href="#" to href="".
  5. Empty containers. These too aren't technically errors, but why go live with a bunch of empty markup containers?

Here's the simple debug CSS that I like to add.

img[alt=""] { border: 3px dotted red; } img:not([alt]) { border: 5px solid red; } a[href="#"] { background-color: lime; } a[href=""] { background-color: lime; } span:empty, li:empty, p:empty, td:empty, th:empty { padding: .5em; background-color: yellow; }

Once the site is cleaned up, remove the debug css, or not.

Happy Debugging!

Comments

Tuesday, Mar 10, 2009 / 5:14pm Mike Kivikoski said…

Debug sheets are a savior, especially when working with a large team or training a client on the proper ways to use their CMS. Thanks for the post.

Wednesday, Mar 11, 2009 / 8:21pm Errol Sayre said…

Very cool. I've often used the old div {border: 1px dotted red;} to troubleshoot layout problems (sometimes just putting a border in fixes them) but hadn't thought to use it with attributes... definitely goin’ in my bag-o.

Comments have been turned off on this blog.
Read something more recent.

Statements and opinions expressed in this blog and any comments made are the private opinions of the respective poster, and, as such, iMarc LLC is neither responsible nor liable for such content.

Meet The Author

Dave Tufts

Vice President, Director of Technology

Search

Recent Blog Posts

Recent Comments

  • I LOLed

    Bill Keeshen commented: Nils, Love the site, congrats! You have a spirited culture as well! Regards, Bill

  • Changing Tradition (for the better)

    Nick commented: This is a fantastic and charitable idea! I would agree, purchasing from and donating to 2 local businesses is a win! Great job iMarc!

  • Content, Content, Content

    dano commented: Totally agree, once I start updating content on a regular basis I start seeing direct and repeat traffic increase exponentially! dano

  • I LOLed

    Pat McNally commented: Hi Nils, I have to be in NY this year for your 12/8 party (great invite), but wish I could be with you. I gave the invite to my 28 year old daughter, Jen Breaker, and urged her to stop in to say hi for me. I hope you and your family have a wonderful and exciting Christmas and holidays. Do you remember what I was doing on New…

  • I LOLed

    Patrick McPhail commented: I was going to go but Nick forgot to leave the keys to the developer shackles.

We heart Visitors

  • iMarc
  • 14 Inn Street
  • Newburyport, MA 01950
  • Phone: (978) 462-8848
  • Fax: (978) 462-8807
  • Directions

Contact Us

Whether you have a huge project or just want to talk about updating your site, we’re here to help. Fill out the form, and we’ll get right back to you.

Contact Us
  • All Fields Required

Close