Basic of SASS
Since Superman has extra power than a normal man, similarly SASS is a super-powered version of CSS. It is actually meant to make CSS more dynamic, organized and productive.
SASS is Syntactically Awesome Stylesheets. It's a CSS Preprocessor. It is written in Ruby and distributed by the Ruby package manager, RubyGems. However it can be implemented with other languages as well, like PHP, Java and C.
SASS consist of the following two syntax:
- SASS: It contains indented code without braces and semicolons
- SCSS: It is indented code with braces and semicolons
One can use either syntax depending on their practice. People who are familair with writing CSS have experienced with writing brackets and semicolons, so they can use SCSS.
Variable
Suppose you have more than 100 CSS files in your project and you want to change the text link color in the entire project. What you will do is, find and replace in the entire project using Dreamweaver or eclipse. It will be a tough job if someone has used the text color Red, #FF0000 or #F00.
In that scenario, variables are useful.
In SASS, we can create a variable for the text link color using $ and use it across the website. So if we want to change it, it requires only one change.
Example 1
- $text-link: #FF0000;
- a
- color: $text-link;
-
- nav a {
- color: $text-link;
- }
Hierarchy
Hierarchy is an important feature of CSS. However it is a tedious job to maintain a long chain of hierarchy. SASS makes it easier. Child elements are added into parent elements, so that a structure can be easily understood. Hierarchy can be easily maintained in SASS.Example 2
- CSS
- .main-container {
- width: 960px;
- margin: 0 auto;
- }
- .main-container .left-column {
- float: left;
- width: 600px;
- }
- .main-container .left-column .left-column-heading {
- font-size: 20px
- }
- SASS
- .main-container {
- width: 960px;
- margin: 0 auto;
- .left-column {
- float: left;
- width: 600px;
- .left-column-heading {
- font-size: 20px
- }
- }
- }

Pankaj BajajPosted Jun 24, 2014, 12:36 AM
great article..very useful information shared. I wasn't aware of this concept even working in CSS since long time...Thanks Dipal
Sukesh MarlaPosted Jun 22, 2014, 4:45 AM
Well done
Sai SherlekarPosted Jun 21, 2014, 2:08 PM
can i get source code of php or java? where u implemented this sass.. pls
Pradeep ShetPosted Jun 21, 2014, 1:57 PM
good 1 (y)
Sanjay SinghPosted Jun 21, 2014, 12:59 PM
very nice & informative article...