tags:

views:

31

answers:

1

I've big css where selector for same things are on different place.

Is there any tool which can rearrange the css based on same type selector?

This is just example.

#main h2 {
    font-size: 2em;
}
#sidebar h3 {
    font-size: 2em;
}

#main h1 {
    font-size: 3em;
}

#sidebar h4 {
    font-size: 1.6em;
}


#main #box h2 {
    font-size: 2em;
}

#sidebar ul li {
    font-size: 1em;
}

it should arranged like this

#main h1 {
    font-size: 3em;
}

#main h2 {
    font-size: 2em;
}

#main #box h2 {
    font-size: 2em;
}

#sidebar h3 {
    font-size: 2em;
}

#sidebar h4 {
    font-size: 1.6em;
}

#sidebar ul li {
    font-size: 1em;
}

if parent selector is same then all should be at same place.

+5  A: 

CSSEdit will sort the selectors for you. BUT: CSS is a cascading style sheet, which means that styles inherit things from above.

If you reorder the elements in the CSS, you are effectively changing the styles - something you probably do not want to do.

webdestroya
then is by hand optimization is the best way for css?
metal-gear-solid
@metal-gear-solid - Sadly, it probably is. That is the best way to make sure you are not breaking your styles.
webdestroya
@webdestroya - BTW I'm on windows
metal-gear-solid
@metal-gear-solid - Oh, well as for windows tools, I have no idea.
webdestroya