Neal Grosskopf Dot Com A NG Designs Site

Neal Grosskopf Dot Com Return To Neal Grosskopf's Home Page a NG Designs Site

Toolbar

  • Skip To
    • Menu
    • Content
  • Validate
    • HTML
    • CSS
    • WAI
  • Font Size
    • Small
    • Medium
    • Large
    • Extra Large
  • Account
    • Create Account
    • Login

Interact

Navigation

  • Home
  • Interact
    • Blog
    • Message Board
    • Open Links
    • Open Videos
    • Photo Gallery
    • Polls
    • Reviews
    • Geek Speak
  • Designs
    • View All Designs
    • Professional
    • Corporate
    • Templates
    • Personal
    • Club
    • NG Designs
    • Web Guides
  • Files
    • Artwork
    • Wallpapers
    • My File Downloads
  • Extras
    • Bookmarklets
    • The Magic 8-Ball
    • Career Builder RSS Feed Generator
    • Monster.com RSS Feed Generator

CSS Diagnostics - Find Deprecated Elements Using CSS

  • Actions
    • View All
    • View Article Statistics
    • View User Statistics
    • Search
    • Subscribe to RSS Feed

Recent Articles:

  • Tracking Outgoing Links in Google Analytics Using Event Tracking and jQuery
  • Tracking Internal Website Campaigns With Google Analytics and PHP
  • Everything You Need to Know About jQuery's .data() Method
  • Google vs. China: How It Will Affect Web Workers
  • Don't Like The New Facebook Home Page? Fix It With 5 Lines of CSS
View All

Subscribe To Feed
loading Subscribers

I'm On Twitter loading

Feb 18

This article is no longer my most current version of CSS Diagnostics. Please see my latest article A Second Look At CSS Diagnostics for the latest version.

I've been getting so many hits on this article that I decided to update it. I have added a few more elements and attributes and changed the colors around. The most severe code is colored red while less severe is colored yellow. There is also a medium severarity that is colored orange. Also remember that elements have solid borders while attributes have dotted boreders. Also check out my Test Suite showing examples of CSS Diagnostics in action.

The other day I was reading Eric Meyer's blog and stumbled across his version of what he likes to call CSS diagnostics. So what is CSS diagnostics? It's a method to highlight those ugly spots in your code, you know <font color="red" size="+1">. Yeah under the hood, somewhere on your website garbage like that exists, yet it's always so hard to hunt down and fix. Never fear CSS diagnostics is here!

CSS Diagnostics allows users to find deprecated elements using CSS and also find find deprecated attributes using CSS. Sorry to have to repeat myself so much here, I'm trying to rank high in SEO with some of these terms since this is still very much uncharted territory.

So how do you use CSS Diagnostics? It's easy! It requires a pretty good knowledge of CSS 2 & CSS 3 selectors and a good knowledge of deprecated HTML elements and attributes.

Follow these steps:

  1. Highlight Deprecated Elements

    applet, basefont, center, dir, font, isindex, menu, s, strike, u, marquee, blink, acronym /* html 5, use abbr */ { border: 5px solid red !important; }
  2. Highlight Deprecated Attributes

    br[clear], hr[noshade], *[color], *[bordercolorlight], *[bordercolordark], *[bordercolor], *[background], *[bgcolor], *[nowrap], body[alink], body[link], body[text], body[vlink], body[bottommargin], body[leftmargin], body[rightmargin], body[topmargin], body[marginheight], body[marginwidth], ol[compact], ul[compact], *[start], img[hspace], img[vspace] *[align], *[valign], *[height], *[width], ul[type], ol[type], li[type], basefont[size], font[size], hr[size] { border: 5px dotted red !important; }
  3. Highlight Proposed Deprecated Elements

    input[type="button"], input[type="reset"], input[type="submit"], tt, embed, big, small { border: 5px solid orange !important; }
  4. Highlight Proposed Deprecated Attributes

    a[target], table[cellpadding], table[cellspacing], map[name], img[name], object[name], form[name], iframe[name], a[name], table[border], img[border], object[border], input[border], object[classid], object[codebase], embed[quality], embed[pluginspage] { border: 5px dotted orange !important; }
  5. Highlight Specific Empty Elements:

    div:empty, span:empty, li:empty, p:empty, td:empty, th:empty { padding: 20px; border: 5px solid yellow !important; }
  6. Highlight Specific Empty Attributes

    *[alt=""], *[title=""], *[class=""], *[id=""], a[href=""], a[href="#"] { border: 5px dotted yellow !important; }

Putting it all together:

Place this code at the end of your stylesheet:

/* Deprecated Elements */ applet, basefont, center, dir, font, isindex, menu, s, strike, u, marquee, blink, acronym /* html 5, use abbr */ { border: 5px solid red !important; } /* Deprecated Attributes */ br[clear], hr[noshade], *[color], *[bordercolorlight], *[bordercolordark], *[bordercolor], *[background], *[bgcolor], *[nowrap], body[alink], body[link], body[text], body[vlink], body[bottommargin], body[leftmargin], body[rightmargin], body[topmargin], body[marginheight], body[marginwidth], ol[compact], ul[compact], *[start], img[hspace], img[vspace] *[align], *[valign], *[height], *[width], ul[type], ol[type], li[type], basefont[size], font[size], hr[size] { border: 5px dotted red !important; } /* Proposed Deprecated Elements */ input[type="button"], input[type="reset"], input[type="submit"], tt, embed, big, small { border: 5px solid orange !important; } /* Proposed Deprecated Attributes */ a[target], table[cellpadding], table[cellspacing], map[name], img[name], object[name], form[name], iframe[name], a[name], table[border], img[border], object[border], input[border], object[classid], object[codebase], embed[quality], embed[pluginspage] { border: 5px dotted orange !important; } /* Empty Elements */ div:empty, span:empty, li:empty, p:empty, td:empty, th:empty { padding: 20px; border: 5px solid yellow !important; } /* Empty Attributes */ *[alt=""], *[title=""], *[class=""], *[id=""], a[href=""], a[href="#"] { border: 5px dotted yellow !important; }

Download The Full Stylesheet

Notes:

It's a good idea to create consistency with your rules. I chose to highlight all attributes in a solid border while highlighting all elements in a dotted border. Also choose different colors for different meanings.

It should also be pointed out that you should use the most standards complient web browser when checking for results. Currently I found that Firefox 2 seems to work best as it comes with many other addons that can work side by side with the custom CSS.

I enjoyed reading Eric's ideas on it but felt I could expand it a bit more. Certainly other's can expand on my version as well. Feel free to contact me if you see something I'm missing.

Sources

  • http://meyerweb.com/eric/tools/css/diagnostics/
  • http://www.w3.org/TR/html401/index/elements.html
  • http://www.w3.org/TR/2005/WD-xhtml2-20050527/elements.html
  • http://www.w3.org/TR/2005/WD-xhtml2-20050527/attributes.html
  • http://www.w3.org/TR/2008/WD-html5-diff-20080122/
  • http://www.html-reference.com/depreciated.htm
  • http://www.codehelp.co.uk/html/deprecated.html

Tags: css, css diagnostics, html, validation ( Add Tag )

Bookmark This Page:
  • Digg loading
  • Delicious loading
  • Re-Tweet loading
  • StumbleUpon loading
  • DZone loading
  • Snipplr
  • Script & Style

Replies:

  • Chris Retlich
    Chris Retlich
    #1

    Mon. February 18, 10:28:44 PM

    Looks like a good idea. They make CSS closer and closer to a programming language every day, don't they?

  • Neal Grosskopf
    Neal Grosskopf
    #2

    Tue. February 19, 1:52:51 PM

    I was really surprised when I applied this CSS to my dev site how many highlighted elements and attributes there are.

    A lot of the CSS 3 selectors are getting really complicated and is starting to look a lot more like regular expressions than style markup. Personally I like it because as HTML gets more and more complicated, we'll need more ways to select the elements within it.

    As far as CSS being a programming language, I see job postings out in California for full time CSS designers...what a dream job.

  • Wayne Zeller
    Wayne Zeller
    #3

    Sun. April 6, 5:33:54 AM

    Firefox users who have the Web Developer add-on can use all this in an extra-cool way: Turn on css editing, go to the css window, scroll to the bottom, and paste in all the code above. You get instant highlighting of all the problems without ever affecting what other visitors to your site will see. (Just plugging it into your css files will highlight your problems for the world to see, but this is a way around that!)

    Thanks for the great code!
    W

  • Neal Grosskopf
    Neal Grosskopf
    #4

    Mon. April 7, 7:43:17 PM

    You can also use the Firefox Accessibility Extension paste this into a custom user stylesheet and turn it on and off whenever you like. I'll have to try your method as well. Thanks for the post!

  • Eric Lightbody
    Eric Lightbody
    #5

    Fri. April 25, 9:32:59 AM

    Very helpful stuff. Maybe if I'm good I can start getting into CSS again ;)

  • Alla Gringaus
    Alla Gringaus
    #6

    Fri. April 10, 2:48:33 PM

    are b, i or u deprecated elements?

  • Neal Grosskopf
    Neal Grosskopf
    #7

    Sat. April 11, 7:06:25 PM

    Alla, no they are not, although I group them in my "proposed deprecated elements" group since they can already by done with CSS. I have since updated this code so check out my most recent article @ http://www.nealgrosskopf.com/tech/thread.asp?pid=17


Reply:

B U I Link Font Color Edit Preview ?
Characters: 0 Textbox Size: [+] [-]
   

  • New Comment
    #8

    Sat. July 31, 1:23:55 PM

Font Size:

  • A
  • A
  • A
  • A

Search:

Places:

  • Blog
  • Message Board
  • Chat Room
  • Geek Speak
  • Open Videos
  • Reviews
  • Tag Cloud
 

Site Links

Site

  • About
  • Contact Me
  • Site Map
  • Site Search

Interact

  • Blog
  • Geek Speak
  • Message Board
  • Open Links
  • Open Videos
  • Photo Gallery
  • Polls
  • Reviews

Random Stuff

  • Hosting by FatCow
  • © Copyright 2005 - 2010
  • Modified: Friday, July 16, 2010
  • Load Time: 0.03 Seconds

Site Coded And Designed By Neal Grosskopf Using No Crappy CMS Or Themes