Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ways to Combine CSS

Tags:

css

I have multiple CSS files (the designer made several, bad iterations) that I need to combine to a single file. However, I don't want to just cat them together. I want to merge the properties for like selectors, ie:

file 1
#mainmenu {width:100%; background:#01568b; text-decoration: none; }

file 2
#mainmenu {width:100%; background:#01568b;}

Where the output would be

#mainmenu {width:100%; background:#01568b; text-decoration: none;}

obviously, this is a simple example, but should explain what I'm looking to do. Are there any tools available, or am I going to have to do this the hard way?

like image 404
Glen Solsberry Avatar asked Oct 17 '11 11:10

Glen Solsberry


People also ask

How do I combine CSS codes?

Use <style type="text/css"></style> in your header tag to merge the css and html into one file. Then paste your css in between the style tags.

What are the 3 ways to apply CSS?

CSS can be added to HTML documents in 3 ways: Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section. External - by using a <link> element to link to an external CSS file.

Can we link 2 CSS to HTML?

Yes, It is possible to include one CSS file in another and it can be done multiple times. Also, import multiple CSS files in the main HTML file or in the main CSS file. It can be done by using @import keyword.


1 Answers

I think you can use the tool CSS Merge for this task.

However you might see some strage stuff going on, due to the importance of styles ect.

Test it in all browsers!

Here is a link http://www.tothepc.com/archives/combine-merge-multiple-css-files/

like image 74
Allan Kimmer Jensen Avatar answered Sep 18 '22 20:09

Allan Kimmer Jensen