How To Convert Old CSS To LESS

 

Using a Tool

With increasing popularity of CSS preprocessor, some new tools and apps that essentially aim to makea web designer’s or developer’s life easier, such as this tool: CSS2Less.
This tool allows us to convert regular CSS into LESS. So, let’s give it a try. I have the following CSS rules from my old file to be converted.
  1. nav {  
  2.     height40px;  
  3.     width: 100%;  
  4.     background#000;  
  5.     border-bottom2px solid #fff;  
  6. }  
  7. nav ul {  
  8.     padding: 0;  
  9.     margin: 0 auto;  
  10. }  
  11. nav li {  
  12.     displayinline;  
  13.     floatleft;  
  14. }  
  15. nav a {  
  16.     color#fff;  
  17.     displayinline-block;  
  18.     width100px;  
  19.     text-shadow1px 1px 0px #000;  
  20. }  
  21. nav li a {  
  22.     border-right1px solid #fff;  
  23.     box-sizing:border-box;  
  24. }  
  25. nav li:last-child a {  
  26.     border-right: 0;  
  27. }  
  28. nav a:hover, nav a:active {  
  29.     background-color#fff;  
  30. }  
Here is the result.
  1. nav a:hover, nav a:active {  
  2.     background-color#fff;  
  3. }  
  4. nav {  
  5.     height40px;  
  6.     width: 100%;  
  7.     background#000;  
  8.     border-bottom2px solid #fff;  
  9.     a {  
  10.         color#fff;  
  11.         displayinline-block;  
  12.         width100px;  
  13.         text-shadow1px 1px 0px #000;  
  14.     }  
  15.     ul {  
  16.         padding: 0;  
  17.         margin: 0 auto;  
  18.     }  
  19.     li:last-child {  
  20.         a {  
  21.             border-right: 0;  
  22.         }  
  23.     }  
  24.     li {  
  25.         displayinline;  
  26.         floatleft;  
  27.         a {  
  28.             border-right1px solid #fff;  
  29.             box-sizing:border-box;  
  30.         }  
  31.     }  
  32. }  
As we can see above, our old CSS is now nested like in LESS.

Limitation

However we can also see some limitations in the results of the conversion. In the old CSS, we have several same colors, such as in these two declarations border-bottom: 2px solid #fff; and border-right: 1px solid #fff; we have both borders in white. In LESS we can actually store this constant value in a Variable.
It also does not nest and separate the pseudo-* with an ampersand (&) symbol, such as in the following rules li:last-child and nav a:hover, nav a:active. They just remain as they are, where we can actually simplify the rulesets this way;
  1. li {  
  2.     &:first-child {  
  3.   
  4.     }  
  5.     a {  
  6.         &:hover {  
  7.   
  8.         }  
  9.         &:active {  
  10.   
  11.         }  
  12.     }  
  13. }  

Conclusion

Despite the limitations it currently still has, this tool can quite helpful in saving our time for nesting CSS rulesets. We only need to do the rest manually; possibly until the the limitations above are resolved.

Category

10 Resources for Designers and Developers 11 Big Tech Trends You'll See in 2013 12/12/12 56 Mashable Stories 60 second Video how to keep laptop work well 70th Golden Globes ads adsense Adsense Tips Advertising AdWords Amazon Android AngryBird Apple Apple's 2012 Year in Review Apps Apps to Spice Up Your Sex Life article Barack Obama Benefits of a Job Search Community Bill Clinton Bing Bitcoins Blackberry blogging blogging secret blogging tools book Book Review; Content Marketing for Dummies Building an Email List Business News Business tips Campaign Websites Celebrities Charlie the Unicorn Chrome Content Spoiler With Simple Animation Creative Ways to Use Your Favorite Running App CSS Design Competition for Kids Digital Media Resources dnt do not track download drive traffic Dropbox Tools e-commerce ebay Effects Social Networks email enterprenour blog Entertainment Expired Domain Business Facebook facebook hacker File Management Film Firefox for Andoid Friends Sex App Gadget Games Geeks george bush george w. bush gmail golden globes Google Google + (plus) Google API Google Capture Google Trends Google Wallet Google XPhone Guest Blog Post Guest Posting Guide to Super Bowl 2013 Betting Guide To: WordPress Development With Microsoft WebMatrix gyroscopes for optical image stabilization history Hopper DVR Horde Hot Advertising Trends of 2012 How to Backup Your Skype Chat & Audio Conversations Online With Simkl html Html 5 HTML Tool hulu Hurricane Sandy instagram's new policy internet Internet Marketing Internet users iOs 6 iPad iPhone Kim Dotcom Laptop LES link building Linkedin Malware Marketing predictions 2013 marketing tips Microsoft Microsoft Surface Pro Mobile App Websites Mobile phone Mobile web Mobile web design monetizing blog money online Motorola Music NBA Negative Target Fixation New year's resolution News nostalgia Notebook Obama Online Education Online Payment Online Stores Palestinian Statehood parental apps PC Jobs Photoshop for Retina Displays Pics Pinterest Plugin porn in vine President Obama's Speech at Vigil for Newtown Victims Promoting Yourself Via Print Publisher Radio Station Review Romsey RoundCube. mail. cpanel Russian Plane Crash Video Search engine security seff identity security SEO SEO 2013 Shop For Geeky Gifts Smartphone-Enabled Website social media Social Networks Social Sites for Families Softaculous software Spam SquirrelMail superbowl 2013 Tablet Teaching Tool Tech Technology Television The Most Reputable Company in U.S. Things I Learned About Tech in 2012 tips Tools twitter latest U.S. UN Vote Universe Unlocked iPhone 5 in the U.S. upgrade script US election US president vote us presidents video Video Conferencing App for Mac Video Marketing Videos Watercooler Ways to Stay Creative While Working From Home Waze web Web design trend 2013 web traffic webtools Wedding What Is Pinterest? White House Why You Should Say No To Multitasking Wi-Fi Smart Scale windows 7 Windows 8 Windows 8 Review Windows RT Review Wirelessly Monitors Your Driving with Dash WomenWeb Wordpress Wordpress Plugin Working From Home writing web Xbox Yahoo YouTube Favorite YouTube Updates