views:

1617

answers:

12

I am working with some CSS that is poorly written to say the least. I am not a design/CSS expert, but I at least understand the C in CSS. While the built in CSS support inside of VS-2008 is far improved over previous versions, it still doesn't quite do what I am looking for.

I was wondering if anyone knew of a good program or utility that will help me to refactor and clean up my CSS much the way that ReSharper helps you with C#.

Some features that would be nice:

  • Examine CSS files and determine ways to extract common styles like font-style, color, etc...
  • Possible plugin to VS-2008 would be awesome!
  • Examine markup files and make some suggestions on improving the current use of classes and styles.
+4  A: 

Firebug is a very good Firefox extension that allows you to examine which CSS declarations are active for which DOM element in your document tree.

Although it does not make any suggestions for improvements, it's a great help when debugging/simplifying CSS code by hand.

The Web Developer extension is also a great help.

vog
I have Firebug and use it pretty extensively, but what I really need is something that will tell me which styles are just dumb. For example setting the font-style and color on every single class. I know this is dumb, but I am looking for a quicker way to get at this information.
Josh
+7  A: 

TopStyle is popular and always the one I hear recommended. It has recommendations on styles etc.

I use Aptana but this doesn't do an refactoring just flags up errors and allows you to target certain browsers. Using this a a decent CSS book may help.

Paul Shannon
I've used TopStyle and I think it's great - although it seems to have got a lot more expensive these days.
Sohnee
+2  A: 

If you're using ASP.NET 2.0, there's ReFactor! for ASP.NET

Mitch Wheat
A: 

I like Expression Web's CSS facilities. But it doesn't do much for minimizing or unifying your CSS. You have to understand how CSS works to use it properly.

Will
+19  A: 

The Dust-Me Selectors Firefox extension can scan a website and tell you what CSS is used and what is not. Removing unused CSS is one good first step in refactoring.

I have often found that when some section is removed from a website, the HTML is removed but the CSS is not.

Liam
This is pretty nice, thanks for the tip Liam!
Josh
It's worth noting that Dust-Me does *not* support checking inline stylesheets, only external ones.
Ben Blank
There is a comment on the download page, which I quote; It NEEDS a tool to ACTUALLY clean the styles ... http://jclaim.sourceforge.net Start it, ... go to menu: General/Handy Tools/Clean CSS ... Feed it the file from this plug-in and your css file and it will show you a clean css file
Vihung
A: 

EditCSS for firefox is amazing.

Michael Neale
Looks interesting, but what can I do with this that I can't do with FireBug
Josh
A: 

I've had good luck using Stylizer in the past. It's nicer and only costs 1/6 of TopStyle.

Joel Coehoorn
Not sure why this was voted down... that program looks pretty awesome!
Josh
+1  A: 

I used to use WestCiv's StyleMaster, which is a pretty good CSS editor / inspector / debugger app. Combine that with the afforementioned Firebug, and you can't help but stay on top of your CSS.

David Heggie
A: 

This site at least helps to sort and minimize your rules: http://www.cleancss.com/
It doesn't get you to where you want to be, but it's a good first step.

Greg
A: 

Maybe CssTidy or CssOptimiser can help to clean-up and make smaller

spinodal
+3  A: 

There's a Ruby gem called HAML that ships with an executable called css2sass. That executable translates CSS into SASS, which is a metalanguage on top of CSS that makes it much easier to refactor (by better illustrating the relationships among your selectors). Might be worth taking a look.

Ben Scofield
+1  A: 

My attempt at playing around with Less for .NET.

Owen
The posted link has been dead for a while, but the github project seems to be being maintained: http://github.com/dotless/dotless/wiki
fordareh