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

  • Changes

    Jean Fitzgerald commented: Congratulations Jeff! It's a great move for you, the company will never regret it. You are one of the most creative people I know too.

  • Changes

    Claire Turcotte commented: Jeffrey! Congratulations. VERY PROUD OF YOU. Send me an answer............ Love, Memere

  • What To Know Before You SEO

    seo course bangalore commented: Wow, awesome blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your website is fantastic, as well as the content! http://seocoursevideo.com/worry/

  • Changes

    Nick Hill commented: Congrats to Will and Jeff!

  • Scrolling, clicking, and the fold

    jay commented: Yeah ,,people will scroll up and down no matter what, now a days a lot of sites have horizontal scroll ..Personally i think scrolling is better than clicking..no time to waste lookin for the link and then clicking..scrolling offers all in one go.

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