Search code examples
csswhitespacespace

how to remove all spaces from a file


I recently downloaded a css file and I accidentally formatted it to this:

.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:"";line-

height:0}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-

shadow:none;background-color:transparent;border:0}

for about 10,000 lines.

How can I remove all the spaces so it looks like:

.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:"";line-height:0}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}

for example.


Solution

  • If you use a text editor like Sublime text, you could use regex to get every space and then delete it.

    Regex:

    \s
    

    If not, you can use simple website tools like:

    CSS Minifier

    Online YUI Compressor

    CSS Compressor