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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
sass

#sass

Table of Contents

About

Chapter 1: Getting started with sass

Remarks

Versions

Examples

Setup

Command Line Tools

GUI Applications

Variables

Importing

Nesting

Comments

Chapter 2: Compass CSS3 Mixins

Introduction

Examples

Set up environment

Installation using Ruby

Create a Project

Use compass

Using CSS3 with compass

Border-radius

Flexbox Example

Conclusion

Chapter 3: Convert units

Examples

Convert px to (r)em

Chapter 4: Extend / Inheritance

Syntax

Parameters

Remarks

1

2

2

2

2

2

2

3

3

3

4

4

6

6

6

6

6

6

6

7

7

7

7

9

9

9

10

10

10

10

Examples

Extend a Class

Extend from Multiple Classes

Chaining Extends

Optional Extends

Placeholders

Extending the parent

Chapter 5: Functions

Syntax

Examples

Basic Functions

Chapter 6: Installation

Remarks

Examples

Mac

Linux

Windows

Chapter 7: Loops and Conditons

Examples

While loop

for loop

Conditional directive (if)

Each loop

Multiple Assignment

Each Loop with maps/ list values

Chapter 8: Mixins

Syntax

Examples

Create and use a mixin

Mixin with variable argument

Sensible defaults

Optional arguments

10

10

10

11

12

12

13

14

14

14

14

15

15

15

15

15

15

16

16

16

16

17

18

18

19

20

20

20

20

20

21

22

@content directive

Chapter 9: Nesting

Examples

Basic nesting

Nesting depth

Problems

Specificity

Reusability

How deep should you nest?

Nesting with @at-root

The parent selector (&)

States and pseudo-elements

Nesting properties

Chapter 10: Operators

Examples

Assignment Operator

Arithmetic Operators

Comparison Operators

Chapter 11: Partials and Import

Examples

Importing

Example

Main benefits

Partials

Example

Chapter 12: Scss useful mixins

Examples

Pure css3 pointer arrows with outline border

Tooltip pointer example

Chapter 13: SCSS vs Sass

Examples

23

24

24

24

24

25

25

25

26

26

27

28

29

31

31

31

31

32

33

33

33

33

34

34

34

35

35

35

36

37

37

Main Differences

Syntax

SCSS:

SASS:

Mixins

Defining a mixin

Including a mixin

Maps

Comments

Single-Line Comment

Multi-Line Comment

Comparision between SCSS & SASS

for loop syntax

Chapter 14: Update Sass version

Introduction

Examples

Windows

Linux

Chapter 15: Variables

Syntax

Examples

Sass

SCSS

Variable Scope

Localize Variables with @at-root directive

Interpolation

Variables in SCSS

Credits

37

37

37

37

38

38

38

38

39

39

39

40

41

43

43

43

43

43

44

44

44

44

44

45

45

46

46

48

About

You can share this PDF with anyone you feel could benefit from it, downloaded the latest version 
from: sass

It is an unofficial and free sass ebook created for educational purposes. All the content is extracted 
from Stack Overflow Documentation, which is written by many hardworking individuals at Stack 
Overflow. It is neither affiliated with Stack Overflow nor official sass.

The content is released under Creative Commons BY-SA, and the list of contributors to each 
chapter are provided in the credits section at the end of this book. Images may be copyright of 
their respective owners unless otherwise specified. All trademarks and registered trademarks are 
the property of their respective company owners.

Use the content presented in this book at your own risk; it is not guaranteed to be correct nor 
accurate, please send your feedback and corrections to info@zzzprojects.com

https://riptutorial.com/

1

Chapter 1: Getting started with sass

Remarks

This section provides an overview of what sass is, and why a developer might want to use it.

It should also mention any large subjects within sass, and link out to the related topics. Since the 
Documentation for sass is new, you may need to create initial versions of those related topics.

Why SASS?

•
•
•
•

Inheritance feature
We can use conditional statements
More functional than traditional CSS
Efficient and clear way to write CSS

Versions

Version

Release Date

3.4.22 (Current) 2016-03-28

3.4.0

3.3.0

3.2.0

2014-08-18

2014-03-07

2012-08-10

Examples

Setup

When it comes to using SASS, there are multiple ways of setting up your workspace. Some 
people prefer to use command line tools (probably Linux people) and others prefer to use GUI 
applications. I'll cover both.

Command Line Tools

The 'Install SASS' page at sass-lang.com covers this quite well. You can use SASS with Ruby 
(which can be installed from a Linux package manager or you can download the installer on 
Windows). macOS comes with Ruby pre-installed.

Once you've installed Ruby, you need to install SASS (in some cases, sudo may not be needed):

https://riptutorial.com/

2

sudo gem install sass

Finally, you can check you've installed SASS with sass -v.

GUI Applications

Whilst there are a number of GUI Applications that you can use, I recommend Scout-App. It auto-
builds and compresses your CSS files for you, on file save and supports macOS, Windows and 
Linux.

Variables

If you have a value that you use often, you can store it in a variable. You could use this to define 
color schemes, for example. You would only have to define your scheme once and then you could 
use it throughout your stylesheets.

To define a variable, you must prefix its name with the $ symbol. (Like you would in PHP.)

You can store any valid CSS property value inside a variable. Such as colors, fonts or URLs.

Example #1:

$foreground: #FAFAFA; 
$background: rgb(0, 0, 0); 

body { 
    color: $foreground; 
    background-color: $background; 
} 

p { 
    color: rgb(25, 25, 20); 
    background-color: $background; 
}

Importing

Let's assume the following scenario: You have two stylesheets: _variables.scss and layout.scss. 
Logically, you keep all your variables inside your variable stylesheet but want to access them from 
your layout stylesheet.

NOTE: You may notice that the variables stylesheet has an underscore ('_') before it's 
name. This is because it's a partial - meaning it's going to be imported.

sass-lang.com says the following about partials: You can create partial Sass files that 
contain little snippets of CSS that you can include in other Sass files. This is a great 
way to modularize your CSS and help keep things easier to maintain. [...] The 
underscore lets Sass know that the file is only a partial file and that it should not be 
generated into a CSS file. Sass partials are used with the @import directive.

https://riptutorial.com/

3

 
 
SCSS variables are great for this scenario. Let's assume that your _variables.scss looks like this:

$primary-color: #333;

You can import it with @import and then the stylesheet's name in quotes. Your layout stylesheet 
may now look like this (take note of there not being an underscore or file extension in the import):

@import 'variables'; 
body { 
  color: $primary-color; 
}

This would output something like the following:

body { 
  color: #333; 
}

Nesting

layout.scss

nav { 
    ul { 
        margin: 0; 
        padding: 0; 
        list-style: none; 
        li { 
            margin: 0 5px; 
           } 
       } 
}

output

nav ul { 
    margin: 0; 
    padding: 0; 
    list-style: none; 
} 
nav ul li { 
    margin: 0 5px; 
}

Comments

SASS supports two types of comments:

•

Inline comments - These only span one line and are usually used to describe a variable or 
block. The syntax is as follows: // Your comment here (you prepend it with a double slash (//) 
and the rest of the line is ignored by the parser.

https://riptutorial.com/

4

•

Multiline comments - These span multiple lines and are usually used to display a copyright or 
license at the top of a document. You can open a multiline comment block with /* and you 
can close a multiline comment block with */. Here's an example:

/* 
   This is a comment 
   It's a multiline comment 
   Also a hiaku 
*/

Read Getting started with sass online: https://riptutorial.com/sass/topic/2045/getting-started-with-
sass

https://riptutorial.com/

5

Chapter 2: Compass CSS3 Mixins

Introduction

Getting started guide using Sass exentsion Compass. Compass is very useful when dealing with 
CSS3 as it provides mixins to write 1 line in order to support every browser using CSS3 features. It 
is also great to include sprite images.

Examples

Set up environment

Open your command line

Installation using Ruby

gem update --system 

gem install compass

Create a Project

compass create <myproject>

This will initialize a compass project. It will add a folder called . The folder will look like have the 
following structure:

File/Folder

description

sass/

Put you sass/scss files in this folder

stylesheets/

In this folder your compiled css will be stored

config.rb

Configure compass - e.g. folder path, sass compilation

Use compass

compass watch

This will compile your sass files every time you change them. The sass folder path can be 
changed inside of the config.rb

https://riptutorial.com/

6

 
Using CSS3 with compass

You can find a complete reference which CSS3 components are supported on this page

In order to use CSS3 in your project Compass provides mixins to support CSS3 features in every 
browser. On top of your Sass/Scss file you have to specify that you want to use compass

@import "compass/css3";

Border-radius

Include border-radius with compass in your sass file:

div { 
    @include border-radius(4px); 
}

CSS output

div { 
  -moz-border-radius: 4px; 
  -webkit-border-radius: 4px; 
  border-radius: 4px; 
}

As you can see you can use the normal CSS name. Just put @include in front of it and use ( ) to 
set your value.

Flexbox Example

.row { 
  @include display-flex; 
  @include flex-direction(row); 
}

CSS Output

.row { 
  display: -webkit-flex; 
  display: flex; 
  -webkit-flex-direction: row; 
  flex-direction: row; 
}

Conclusion

https://riptutorial.com/

7

This are only two examples. Compass provides much more CSS3 mixins. It is very handy to use 
Compass and you don't have to worry that you have forgot defining a CSS3 component for a 
specified browser. If the browser supports the CSS3 feature, compass will define it for you.

Read Compass CSS3 Mixins online: https://riptutorial.com/sass/topic/10600/compass-css3-mixins

https://riptutorial.com/

8

Chapter 3: Convert units

Examples

Convert px to (r)em

To convert px to em or rem you can use the following function:

@function rem-calc($size, $font-size : $font-size) { 
    $font-size: $font-size + 0px; 
    $remSize: $size / $font-size; 
    @return #{$remSize}rem; 
} 

@function em-calc($size, $font-size : $font-size) { 
    $font-size: $font-size + 0px; 
    $remSize: $size / $font-size; 
    @return #{$remSize}em; 
}

The $font-size is the original font size.

For example:

$font-size: 14; 

body { 
  font-size: #{$font-size}px; 
  font-size: rem-calc(14px); // returns 1rem 
  // font-size: rem-calc(28); // returns 2rem 
}

Read Convert units online: https://riptutorial.com/sass/topic/6661/convert-units

https://riptutorial.com/

9

 
 
Chapter 4: Extend / Inheritance

Syntax

•
•
•
•

@extend .<className>
@extend .<className>, .<className>
@extend .<className> !optional
@extend .<className>, .<className> !optional

Parameters

Parameter Details

className The class that you want to extend.

Remarks

Sass' @extend rule allows you to share CSS properties across multiple classes, keeping code DRY 
and easier to read.

Examples

Extend a Class

.message 
  color: white 

.message-important 
  @extend .message 
  background-color: red

This will take all of the styles from .message and add them to .message-important. It generates the 
following CSS:

.message, .message-important { 
  color: white; 
} 

.message-important { 
  background-color: red; 
}

Extend from Multiple Classes

.message 
  color: white 

https://riptutorial.com/

10

 
 
.important 
  background-color: red 

.message-important 
  @extend .message, .important

In the above code @extend is used in one line to add multiple classes' code to .message-important, 
however, it is possible to use one extend per line like this:

.message-important 
    @extend .message 
    @extend .important

Either one of these methods will generate the following CSS:

.message, .message-important { 
  color: white; 
} 

.important, .message-important { 
  background-color: red; 
}

Chaining Extends

.message 
  color: white 
  background: black 

.message-important 
  @extend .message 
  font-weight: bold 

.message-error 
  @extend .message-important 
  font-style: italic

This code causes .message-error to extend from .message-important, which means that it will 
contain code from both .message-important and .message, since .method-important extends from 
.message. This results in the following CSS:

.message, .message-important, .message-error { 
  color: white; 
  background: black; 
} 

.message-important, .message-error { 
  font-weight: bold; 
} 

.message-error { 
  font-style: italic; 
}

https://riptutorial.com/

11

 
 
 
 
 
 
 
Disclaimer: Make sure that the class(es) you are extending from occur only once in the 
code, otherwise Sass may generate some messy, convoluted CSS.

Optional Extends

Sometimes, you may want an @extend to be optional, and not require the specified class to exist in 
your code.

.message-important 
  @extend .message !optional 
  background: red

This will result in the following CSS:

.message-important { 
  background: red; 
}

Disclaimer: This is useful during development when you may not have all of your code 
written yet and don't want errors, but it should probably be removed in production because 
it could lead to unexpected results.

Placeholders

Sometimes you will create classes that won't be used in their own right, rather only be extended 
inside other rule sets. This means that the compiled CSS file will be larger than it needs to be. 
Placeholder selectors solve this problem.

Placeholder selectors are similar to class selectors, but they use the percent character (%) instead 
of the (.) used for classes. They will not show up in the compiled CSS.

%button { 
    border: 5px solid black; 
    border-radius: 5px; 
    margin: 0; 
} 

.error-button { 
    @extend %button; 
    background-color: #FF0000; 
} 

.success-button { 
    @extend %button; 
    background-color: #00FF00; 
}

This will compile to the following CSS:

.error-button, .success-button { 
    border: 5px solid black; 
    border-radius: 5px; 

https://riptutorial.com/

12

 
 
    margin: 0; 
} 

.error-button { 
    background-color: #FF0000; 
} 

.success-button { 
    background-color: #00FF00; 
}

Extending the parent

Typically trying to extend the parent like so:

.parent { 
  style: value; 

  @extend &; 
}

Will result in an error, stating that the parent cannot be extended. This makes sense, but there's a 
workaround. Simply store the parent selector in a variable.

.parent { 
  $parent: &; 
  style: value; 
  @extend #{&}; 
}

There's no benefit to doing this in the above example, however this gives you the power to wrap 
parent styles from within an included mixin.

Read Extend / Inheritance online: https://riptutorial.com/sass/topic/2894/extend---inheritance

https://riptutorial.com/

13

 
 
 
Chapter 5: Functions

Syntax

•

@function function-name(parameter) { /* Function body */ }

Examples

Basic Functions

A function is similar in look to a mixin but it doesn't add any styles, it only returns a value. 
Functions should be used to prevent repeated logic in your styles.

Sass has some built-in functions that are called using the standard CSS function syntax.

h1 { 
    background: hsl(0, 25%, 50%); 
}

Functions are declared using the below syntax,

@function multiply(x, y) { 
    @return x * y; 
} 

// example use below 
h1 { 
    margin-top: multiply(10px, 2); 
}

In the code above, @function declares a function, and @return signifies the return value.

Read Functions online: https://riptutorial.com/sass/topic/4782/functions

https://riptutorial.com/

14

 
Chapter 6: Installation

Remarks

This covers Ruby only, which is the main SASS compiler for many systems but other options exist. 
A very common one for any node developer would be node-sass which could be easier, and 
orders of magnitude faster, for many users.

Examples

Mac

Ruby comes pre-installed on a Mac computer.

Follow the instructions below to install Sass:

1. 
2. 
3. 
4. 

Open CMD
Run gem install sass
If you get an error message, try sudo gem install sass
Check it works using sass -v

Linux

Ruby will need to be installed first before setup. You can install Ruby through the apt package 
manager, rbenv, or rvm.

Then Run

sudo su -c "gem install sass"

Windows

The fastest way to get Ruby on your Windows computer is to use Ruby Installer. It's a single-click 
installer that will get everything set up for you super fast. After installing Ruby, follow the 
instructions below to install Sass:

1. 
2. 
3. 
4. 

Open CMD
Run gem install sass
If you get an error message, try sudo gem install sass
Check it works using sass -v

Read Installation online: https://riptutorial.com/sass/topic/2052/installation

https://riptutorial.com/

15

Chapter 7: Loops and Conditons

Examples

While loop

The @while directive will loop over a block of code until the condition specified becomes false. In 
the following example, this loop will run until $font-size <= 18 while incrementing the value for 
$font-size by 2.

$font-size: 12; 

@while $font-size <= 18 { 
    .font-size-#{$font-size} { 
        font-size: ($font-size * 1px); 
    } 

    $font-size: $font-size + 2; 
}

Output of above code

.font-size-12 { 
  font-size: 12px; 
} 

.font-size-14 { 
  font-size: 14px; 
} 

.font-size-16 { 
  font-size: 16px; 
} 

.font-size-18 { 
  font-size: 18px; 
}

for loop

The @for directive allows you to loop through some code for a set amount of iterations and has two 
forms:

•
•

@for <var> from <start> through <end> {}
@for <var> from <start> to <end> {}

The difference in the two forms is the through and the to; the through keyword will include the 
<end> in the loop where to will not; using through is the equivalent of using >= or <= in other 
languages, such as C++, JavaScript, or PHP.

Notes

https://riptutorial.com/

16

 
 
 
 
 
•
•

Both <start> and <end> must be integers or functions that return integers.
When <start> is greater than <end> the counter will decrement instead of increment.

SCSS Example

@for $i from 1 through 3 { 
  .foo-#{$i} { width: 10px * $i; } 
} 

// CSS output 
.foo-1 { width: 10px; } 
.foo-2 { width: 20px; } 
.foo-3 { width: 30px; }

Conditional directive (if)

The @if control directive evaluates a given expression and if it returns anything other than false, it 
processes its block of styles.

Sass Example

$test-variable: true !default 

=test-mixin 
  @if $test-variable 
    display: block 
  @else 
    display: none 

.test-selector 
  +test-mixin

SCSS Example

$test-variable: true !default 

@mixin test-mixin() { 
  @if $test-variable { 
    display: block; 
  } @else { 
    display: none; 
  } 
} 

.test-selector { 
  @include test-mixin(); 
}

The above examples produces the following CSS:

.test-selector { 
  display: block; 
}

https://riptutorial.com/

17

 
 
 
 
 
Each loop

The @each directive allows you to iterate through any list or map. It takes the form of @each $var 
or <list or map> {} where $var can be any variable name and <list or map> can be anything that 
returns a list or map.

In the following example, the loop will iterate through the $authors list assigning each item to 
$author, process its block of styles using that value of $author, and proceed to the next item in the 
list.

SCSS Example

$authors: "adam", "steve", "john"; 
@each $author in $authors { 
    .photo-#{$author} { 
      background: image-url("avatars/#{$author}.png") no-repeat 
    } 
}

CSS Output

.photo-adam { 
  background: image-url("avatars/adam.png") no-repeat; 
} 
.photo-steve { 
  background: image-url("avatars/steve.png") no-repeat; 
} 
.photo-john { 
  background: image-url("avatars/john.png") no-repeat; 
}

Multiple Assignment

Multiple assignment allows you to gain easy access to all of the variables by declaring multiple 
variables in the @each directive.

Nested Lists

To have easy access to all the nested elements, you may declare separate variables to match 
each nested element. Be sure you have the correct amount of variables and nested elements. In 
the following example, an each loop is iterating through a list of three elements each of which 
contains three elements nested. Having the wrong amount of declared variables will result in a 
compiler error.

@each $animal, $color, $cursor in (puma, black, default), 
                                  (sea-slug, blue, pointer), 
                                  (egret, white, move) { 
  .#{$animal}-icon { 
    background-image: url('/images/#{$animal}.png'); 
    border: 2px solid $color; 
    cursor: $cursor; 

https://riptutorial.com/

18

  } 
}

Maps

Multiple assignment works for Maps as well but is limited to only two variables, a variable to 
access the key and a variable to access the value. The names $key and $value are arbitary in the 
following example:

@each $key, $value in ('first': 1, 'second': 2, 'third': 3) { 
  .order-#{$key} { 
    order: $value; 
  } 
}

Each Loop with maps/ list values

In the below example value in map $color-array is treated as list of pairs.

SCSS Input

$color-array:( 
  black: #4e4e4e, 
  blue: #0099cc, 
  green: #2ebc78 
); 
@each $color-name, $color-value in $color-array { 
  .bg-#{$color-name} { 
    background: $color-value; 
  } 
}

CSS Output

.bg-black { 
  background: #4e4e4e; 
} 

.bg-blue { 
  background: #0099cc; 
} 

.bg-green { 
  background: #2ebc78; 
}

Read Loops and Conditons online: https://riptutorial.com/sass/topic/2671/loops-and-conditons

https://riptutorial.com/

19

 
 
Chapter 8: Mixins

Syntax

•

@mixin mixin-name ($argument1, $argument, ...){ ... }

Examples

Create and use a mixin

To create a mixin use the @mixin directive.

@mixin default-box ($color, $borderColor) { 
    color: $color; 
    border: 1px solid $borderColor; 
    clear: both; 
    display: block; 
    margin: 5px 0; 
    padding: 5px 10px; 
}

You can specify a list of arguments inside a parenthesis following the mixin's name. Remember to 
start your variables with $ and separate them with commas.

To use the mixin in another selector, use the @include directive.

footer, header{ @include default-box (#ddd, #ccc); }

The styles from the mixin will now be used in the footer and header, with the value #ccc for the 
$color variable and #ddd for the $borderColor variable.

Mixin with variable argument

There are some cases in mixins where there can be single or multiple arguments while using it. 
Let's take a case of border-radius where there can be single argument like border-radius:4px; or 
multiple arguments like border-radius:4px 3px 2px 1px;.

Traditional with Keyword Arguments mixing will be like below:-

@mixin radius($rad1, $rad2, $rad3, $rad4){ 
 -webkit-border-radius: $rad1 $rad2 $rad3 $rad4; 
 -moz-border-radius: $rad1 $rad2 $rad3 $rad4; 
 -ms-border-radius: $rad1 $rad2 $rad3 $rad4; 
 -o-border-radius: $rad1 $rad2 $rad3 $rad4; 
 border-radius: $rad1 $rad2 $rad3 $rad4; 
}

And used as

https://riptutorial.com/

20

.foo{ 
    @include radius(2px, 3px, 5px, 6px) 
}

The above example is complex (to code, read and maintain) and if you can't pass only one value 
or two values, it will throw an error, and to use one, two or there values you have to define three 
other mixins.

By using variable Argument you don't have to worry about how many arguments can you pass. 
Variable arguments can be declared by defining a variable name followed by three dots(...). 
Following is an example of a variable argument.

@mixin radius($radius...) 
{ 
    -webkit-border-radius: $radius; 
    -moz-border-radius: $radius; 
    -ms-border-radius: $radius; 
    -o-border-radius: $radius; 
    border-radius: $radius; 
}

And used as

.foo{ 
    @include radius(2px 3px 5px 6px) 
} 
.foo2{ 
    @include radius(2px 3px) 
} 
.foo3{ 
    @include radius(2px) 
}

The above example is much simpler (to code, maintain and read), you need not worry about how 
many arguments are about to come - is it one or more than one.

If there is more than one argument and in any case you want to access the second argument, you 
can do it by writing propertyname : nth(variable_name, 2).

Sensible defaults

SASS gives you the ability to omit any parameter except the ones you want to overwrite of course. 
Let's take again the default-box example:

@mixin default-box ($color: red, $borderColor: blue) { 
    color: $color; 
    border: 1px solid $borderColor; 
    clear: both; 
    display: block; 
    margin: 5px 0; 
    padding: 5px 10px; 
}

https://riptutorial.com/

21

Here we'll now call the mixin having overwritten the second parameter

footer, header{ @include default-box ($borderColor: #ccc); }

the value of $borderColor is #ccc, while $color stays red

Optional arguments

SASS's optional arguments let you use a parameter only if you specify its value; otherwise, it will 
be ignored. Let's take an example of the following mixin:

@mixin galerie-thumbnail ($img-height:14em, $img-width: null) { 
    width: $img-width; 
    height: $img-height; 
    outline: 1px solid lightgray; 
    outline-offset: 5px; 
}

So a call to

.default { 
  @include galerie-thumbnail; 
} 
.with-width { 
  @include galerie-thumbnail($img-width: 12em); 
} 
.without-height { 
  @include galerie-thumbnail($img-height: null); 
}

will simply output the following in the CSS file:

.default { 
  height: 14em; 
  outline: 1px solid lightgray; 
  outline-offset: 5px; 
} 

.with-width { 
  width: 12em; 
  height: 14em; 
  outline: 1px solid lightgray; 
  outline-offset: 5px; 
} 

.without-height { 
  outline: 1px solid lightgray; 
  outline-offset: 5px; 
}

SASS doesn't output properties with null as their value, which is very helpful when we need to 
include an optional argument in our call or not.

https://riptutorial.com/

22

 
 
@content directive

Mixins can be passed a block of SASS compliant code, which then becomes available within the 
mixin as the @content directive.

@mixin small-screen { 
  @media screen and (min-width: 800px;) { 
    @content; 
  } 
} 

@include small-screen { 
  .container { 
    width: 600px; 
  } 
}

And this would output:

  @media screen and (min-width: 800px;) { 
    .container { 
      width: 600px; 
    } 
  }

Mixins can use the @content directive and still accept parameters.

@mixin small-screen($offset) {...

Read Mixins online: https://riptutorial.com/sass/topic/2131/mixins

https://riptutorial.com/

23

 
Chapter 9: Nesting

Examples

Basic nesting

Whenever you declare a new rule inside another rule it is called nesting. With basic nesting, as 
shown below, the nested selector will be compiled as a new CSS selector with all its parents 
prepended, separated by a space.

// SCSS 
.parent { 
  margin: 1rem; 

  .child { 
    float: left; 
  } 
} 

// CSS output 
.parent { 
  margin: 1rem; 
} 

.parent .child { 
  float: left; 
}

Nesting depth

Nesting is a very powerful feature, but should be used with caution. It can happen quite easily and 
quickly, that you start nesting and carry on including all children in a nest, of a nest, of a nest. Let 
me demonstrate:

// SCSS 
header { 
  // [css-rules] 

  .holder { 
    // [css-rules] 

    .dropdown-list { 
      // [css-rules] 

      ul { 
        // [css-rules] 

        li { 
          margin: 1rem 0 0 1rem; 
        } 
      } 
    } 
  } 

https://riptutorial.com/

24

 
 
 
 
 
 
 
} 

// CSS output of the last rule 
header .holder .dropdown-list ul li { 
  margin: 1rem 0 0 1rem; 
}

Problems

Specificity

The li from the example above has a margin set. Let's say we want to override this in a media-
query later on.

@media (max-width: 480) { 

  // will not work 
  .dropdown-list ul li { 
    margin: 0; 
  } 

  // will work 
  header .holder .dropdown-list ul li { 
    margin: 0; 
  } 
}

So by nesting too deep consequently you'll have to nest deep again whenever you want to 
overwrite a certain value. Even worse, this is often where the rule !important comes to use.

@media (max-width: 480) { 

  // BIG NO-NO, don't do this 
  .dropdown-list ul li { 
    margin: 0 !important; 
  }

Why is the !important-rule is a bad idea

You should write your SCSS in a good fashion that these workarounds aren't even necessary in 
the first place. Using !important on such a minor issue already will lead you down a rabbit hole!

Reusability

This is fairly similar to the specificity problem, but worth pointing out separately. If you style 
something like a button or even a dropdown, you might want to reuse those styles somewhere 
else on your page.

By nesting too deeply your styles are only bound to the elements sitting inside the most outer 
parent (the element at the top of your SCSS). This leads you to copy styles and paste them 
somewhere else again. Possibly in an other nested rule.

https://riptutorial.com/

25

 
 
 
 
Your stylesheets will become larger and larger and more difficult to maintain.

How deep should you nest?

Most styleguides set the maximum depth to 2. This is good advice in general, as there are only 
very few occasions where you'd want to nest deeper. Most of the time, 2 is enough.

Nesting with @at-root

Nesting is probably most often used to create more specific selectors, but it can also be used 
simply for code organization. Using the @at-root directive, you can ‘jump out’ of where you nest it 
in your Sass, bringing you back at the top level. Doing this allows you to keep styles grouped 
without creating more specificity than you need.

For example, you could to something like this :

.item { 
    color: #333; 

    @at-root { 
        .item-wrapper { 
            color: #666; 

            img { 
                width: 100%; 
            } 
        } 
    } 

    .item-child { 
        background-color: #555; 
    } 
}

That would compile to this :

.item { 
  color: #333; 
} 
.item-wrapper { 
  color: #666; 
} 
.item-wrapper img { 
  width: 100%; 
} 
.item .item-child { 
  background-color: #555; 
}

By doing this, all of our styles related to the .item class are together in the SCSS, but we don't 
necessarily need that class in every selector.

https://riptutorial.com/

26

 
 
 
Excluding contexts

By default declarations inside @at-root will appear in any context. This means that rules inside a 
@media block for instance will remain there.

@media print { 
  .item-wrapper { 
    @at-root { 
      .item { 
        background: white; 
      } 
    } 
  } 
} 

// Will compile to 
@media print { 
  .item { 
    background: white; 
  } 
}

This is not always desired behavior, so you can exclude the media context, by passing media to the 
the without option of the @at-root directive.

@at-root (without: media) {..

For more information, see the official documentation

The parent selector (&)

Nesting is great for keeping related selectors together to make it easier for future developers to 
understand your code. The parent selector, represented by an ampersand ("&") can help do that in 
more complex situations. There are several ways its can be used.

Create a new selector that requires both the parent selector and another on the same element by 
placing the new selector directly after a parent selector.

// SCSS 
.parent { 

  &.skin { 
    background: pink; 
  } 
}

// CSS output 
.parent.skin { 
  background: pink; 
}

Have the parent appear after a nested selector in the compiled CSS by placing the parent selector 
after the nested selector.

https://riptutorial.com/

27

 
 
// SCSS 
.parent { 

  .wrapper & { 
    border: 1px solid black; 
  } 
}

// CSS output 
.wrapper .parent { 
  border: 1px solid black; 
}

States and pseudo-elements

Besides using nesting for classes and children, nesting with the parent selector is also commonly 
used to combine the states of :active, :hover and :focus for links.

// SCSS 
a { 
  color: blue; 

  &:active, 
  &:focus { 
    color: red; 
  } 

  &:visited { 
    color: purple; 
  } 
}

// CSS output 
a { 
  color: blue; 
} 

a:active, 
a:focus { 
  color: red; 
} 

a:visited { 
  color: purple; 
}

Similarly, you can style pseudo-elements by nesting with the parent selector.

// SCSS 
.parent { 

  &::after { 
    display: table; 
    clear: both; 
    content: ''; 

https://riptutorial.com/

28

 
 
 
 
 
 
  } 

  &::only-child { 
    font-weight: bold; 
  } 
}

// CSS output 
.parent::after { 
  display: table; 
  clear: both; 
  content: ''; 
} 

.parent::only-child { 
  font-weight: bold; 
}

Nesting properties

Some CSS properties belong to a namespace, for instance border-right belongs to the border 
namespace. To write less, we can utilize property nesting, and skip these prefixes, even on 
multiple levels.

If we needed to create a border on the right and left of a class named .borders we could write this:

 //SCSS 
 .borders { 
    border: 2px dashed blue; 
    border: { 
        left: 1px solid black; 
        right: 1px solid red; 
    } 
  } 

 // CSS output 
 .borders { 
    border: 2px dashed blue; 
    border-left: 1px solid black; 
    border-right: 1px solid red; 
  } 

This saves us having to write border-right and border-left, however we are still writing repetitive 
code with the lines 1px solid black and 1px solid red. We can write still less repetitive CSS with 
the folowing:

// SCSS 
.borders { 
  border: 2px dashed blue { 
    left: 1px solid black; 
    right: { 
      color: red; 
    } 
  } 

https://riptutorial.com/

29

 
 
 
 
} 

// CSS output 
.borders { 
   border: 2px dashed blue; 
   border-left: 1px solid black; 
   border-right-color: red; 
}

Read Nesting online: https://riptutorial.com/sass/topic/2178/nesting

https://riptutorial.com/

30

 
Chapter 10: Operators

Examples

Assignment Operator

Sass uses the colon (:) operator to assign values to variables.

Example

$foreColor: red; 

p { 
    color: $foreColor; 
}

Arithmetic Operators

Sass supports the following standard arithmetic operators:

Operator Description

+

–

*

/

%

Addition

Subtraction

Multiplication

Division

Remainder

Examples

p { 
    font-size: 16px + 4px; // 20px 
}

h3 { 
    width: 2px * 5 + 12px; // 22px 
}

h2 { 
    width: 8px + (12px / 2) * 3; // 26px 
}

Normal order of operations applies as usual.

https://riptutorial.com/

31

 
Comparison Operators

Sass supports all the usual comparison operators: <,>,==,!=,<=,>=.

Examples

(10px == 10) // Returns true

("3" == 3) // Returns false

$padding: 10px; 
$padding <= 8px; // Returns false

Read Operators online: https://riptutorial.com/sass/topic/3047/operators

https://riptutorial.com/

32

Chapter 11: Partials and Import

Examples

Importing

Using @import allows you to split up your files into multiple smaller files. This makes sense, as you 
are able to keep better structure for your stylesheets and avoid very large files.

Example

Let's say you have a few files.

- application.scss 
- header.scss 
- content 
  |-- article.scss 
  '-- list.scss 
- footer.scss

Your main stylesheet application.scss can import all files as well as define its own styles.

// application.scss 
// Import files: 
@import 'header.scss'; 
@import 'content/article.scss'; 
@import 'content/list.scss'; 
@import 'footer.scss'; 

// other styles in application.scss 
body { 
  margin: 0; 
}

Note that you can also omit the .scss extension so you could write @import 'header'; instead of 
@import 'header.scss'.

This leads to application.scss having all imported .scss included in the compiled file you serve to 
the client (browser). In this case your compiled file would be application.css which you include in 
your html.

<html> 
  <head> 
    <link rel="stylesheet" type="text/css" href="/application.css?v=18c9ed25ea60"> 
  </head> 
  <body> 
    ... 
  </body> 
</html>

https://riptutorial.com/

33

 
Although you are working with multiple files you only serve one file, eliminating the need for 
multiple requests (one for each file) and speeding up the load time for your visitors.

Main benefits

•
•

Better structure for development using folder and multiple files
Serving only one file to the client (browser)

Partials

You can create partial files that contain smaller snippets of your stylesheets. This allows you to 
modularize your CSS and allows for better structure of your stylesheets. A partial is a Sass file 
named with a leading underscore, i.e: _partial.scss. The underscore lets Sass know that the 
specific file is a partial and it will not be generated into a CSS file.

Sass partials are meant to be used with the @import directive. When using @import, you can omit 
the leading underscore.

Example

Supposing you have a file structure with partials like this

- main.scss 
- _variables.scss 
- content 
  |-- _buttons.scss 
  '-- _otherelements.scss

You can include those partials in your main.scss file as follows (leading underscores and file 
extensions are omitted in this example):

// main.scss - Imports: 
@import 'variables'; 
@import 'content/buttons'; 
@import 'content/otherelements';

Read Partials and Import online: https://riptutorial.com/sass/topic/2893/partials-and-import

https://riptutorial.com/

34

Chapter 12: Scss useful mixins

Examples

Pure css3 pointer arrows with outline border

!!! Container should be positioned relatively or absolutely

$direction - top, bottom, left, right

$margin - margin by the edge in $direction. For top and bottom direction - it's from left to right. 
For left and right - it's from top to bottom.

$colors - first is a border color, second - is a background color (maybe it's better to inherit 
background color from a parent)

$arrowSide - is a relative size of an arrow

$isInset - arrow is inside (true) or outside of it's container

Here is a working Plunker https://plnkr.co/edit/PRF9eLwmOg8OcUoGb22Y?p=preview

%pointer-core { 
    content: " "; 
    position: absolute; 
    border: solid transparent; 
    z-index: 9999; 
} 

@mixin pointer($direction, $margin: 10px, $colors: (#999, $gray), $arrowSide: 8px, $isInset: 
false){ 

    $opposites: ( 
        top: bottom, 
        bottom: top, 
        left: right, 
        right: left 
    ); 

    $margin-direction: ( 
        top: left, 
        bottom: left, 
        left: top, 
        right: top 
    ); 

    &:before { 
        @extend %pointer-core; 
        border-width: $arrowSide; 

        @if $isInset { 
            border-#{$direction}-color: nth($colors, 1); 
            #{$direction}: -1px; 
        } 

https://riptutorial.com/

35

 
 
 
 
 
        @else 
        { 
            border-#{map-get($opposites, $direction)}-color: nth($colors, 1); 
            #{map-get($opposites, $direction)}: 100%; 
        } 

        #{map-get($margin-direction, $direction)}: 0; 

        margin-#{map-get($margin-direction, $direction)}: $margin - 1; 
    } 

    &:after { 
        @extend %pointer-core; 
        border-width: $arrowSide - 1; 

        @if $isInset { 
            border-#{$direction}-color: nth($colors, 2); 
            #{$direction}: -1px; 
        } 
        @else 
        { 
            border-#{map-get($opposites, $direction)}-color: nth($colors, 2); 
            #{map-get($opposites, $direction)}: 100%; 
        } 

        #{map-get($margin-direction, $direction)}: 0; 

        margin-#{map-get($margin-direction, $direction)}: $margin; 
    } 
}

Tooltip pointer example

$color-purple-bg: #AF6EC4; 
$color-purple-border: #5D0C66; 

$color-yellow-bg: #E8CB48; 
$color-yellow-border: #757526; 

.tooltip { 
    position: relative; 

    &--arrow-down { 
        @include pointer('bottom', 30px, ($color-purple-border, $color-purple-bg), 15px); 
    } 

    &--arrow-right { 
        @include pointer('right', 60px, ($color-yellow-border, $color-yellow-bg), 15px); 
    } 
}

Read Scss useful mixins online: https://riptutorial.com/sass/topic/6605/scss-useful-mixins

https://riptutorial.com/

36

 
 
 
 
 
 
 
 
 
 
 
Chapter 13: SCSS vs Sass

Examples

Main Differences

Although people often say Sass as the name of this CSS-preprocessor, they often mean the SCSS-
syntax. Sass uses the .sass file extension, while SCSS-Sass uses the .scss extension. They are both 
referred to as "Sass".

Speaking generally, the SCSS-syntax is more commonly used. SCSS looks like regular CSS with 
more capabilities, whereas Sass looks quite different to regular CSS. Both syntaxes have the same 
abilities.

Syntax

The main differences are that Sass doesn't use curly brackets or semicolons, where SCSS does. Sass 
is also whitespace-sensitive, meaning you have to indent correctly. In SCSS, you can format and 
indent your rules as you please.

SCSS:

// nesting in SCSS 
.parent { 
  margin-top: 1rem; 

  .child { 
    float: left; 
    background: blue; 
  } 
}

SASS:

// nesting in Sass 
.parent 
  margin-top: 1rem 

  .child 
    float: left 
    background: blue

After compilation, both will produce the same following CSS:

https://riptutorial.com/

37

 
 
.parent { 
  margin-top: 1rem; 
} 
.parent .child { 
  float: left; 
  background: blue; 
}

Mixins

Sass tends to be the more "lazy" syntax. Nothing illustrates this nicer than how you define and 
include mixins.

Defining a mixin

= is how you define a mixin in Sass, @mixin in SCSS.

// SCSS 
@mixin size($x: 10rem, $y: 20rem) { 
  width: $x; 
  height: $y; 
} 

// Sass 
=size($x: 10rem, $y: 20rem) 
  width: $x 
  height: $y

Including a mixin

+ is how you include in Sass, @include in SCSS.

// SCSS 
.element { 
  @include size(20rem); 
} 

// Sass 
.element 
  +size(20rem)

Maps

When it comes to maps, usually SCSS is the easier syntax. Because Sass is indent-based, your 
maps have to be saved in one line.

// in Sass maps are "unreadable" 
$white: ( white-50: rgba(255, 255, 255, .1), white-100: rgba(255, 255, 255, .2), white-200: 
rgba(255, 255, 255, .3), white-300: rgba(255, 255, 255, .4), white-400: rgba(255, 255, 255, 
.5), white-500: rgba(255, 255, 255, .6), white-600: rgba(255, 255, 255, .7), white-700: 

https://riptutorial.com/

38

 
 
rgba(255, 255, 255, .8), white-800: rgba(255, 255, 255, .9), white-900: rgba(255, 255, 255, 1 
)

Because you can format your code on multiple lines with SCSS, you can format your maps to be 
more readable.

// in SCSS maps are more readable 
$white: ( 
  white-50: rgba(255, 255, 255, .1), 
  white-100: rgba(255, 255, 255, .2), 
  white-200: rgba(255, 255, 255, .3), 
  white-300: rgba(255, 255, 255, .4), 
  white-400: rgba(255, 255, 255, .5), 
  white-500: rgba(255, 255, 255, .6), 
  white-600: rgba(255, 255, 255, .7), 
  white-700: rgba(255, 255, 255, .8), 
  white-800: rgba(255, 255, 255, .9), 
  white-900: rgba(255, 255, 255, 1) 
);

Comments

Comments in Sass vs. Scss are largely similar, except when multi-lines are concerned. SASS multi-
lines are indentation-sensitive, while SCSS relies on comment terminators.

Single-Line Comment

style.scss

// Just this line will be commented! 
h1 { color: red; }

style.sass

// Exactly the same as the SCSS Syntax! 
h1 
  color: red

Multi-Line Comment

style.scss

Initiator: /*

Terminator: */

/* This comment takes up 

https://riptutorial.com/

39

 * two lines. 
 */ 
h1 { 
   color: red; 
}

This will style h1 elements with the color red.

style.sass

Now, SASS has two initiators, but no respective terminators. Multiline comments in SASS are 
sensitive to indentation levels.

Initiators: // and /*

// This is starts a comment, 
   and will persist until you 
   return to the original indentaton level. 
h1 
  color: red

This will style h1 elements with the color red.

The same can be done with the /* Initiator:

/* This is starts a comment, 
   and will persist until you 
   return to the original indentaton level. 
h1 
  color: red

So there you have it! The main differences between comments in SCSS and SASS!

Comparision between SCSS & SASS

•

•

•

•

•

SCSS syntax resembles more like a CSS syntax but SASS syntax is little bit different from SCSS but 
both produces exactly the same CSS code.
In SASS we are not ending the style properties with semicolon(;) but in SCSS we are ending 
the style properties with (;).
In SCSS we used paranthesis {} to close the style properties but in SASS we don't use 
paranthesis.
Indentation is very important in SASS. It will define the nested properties in the class or id of 
the element.
In scss we can define multiple variables in single line but in SASS we can't do.

https://riptutorial.com/

40

for loop syntax

With the release of sass 3.3 and plus version the @if and else conditions syntax got same. we can 
now use expressions with not only scss but also sass.

sass syntax

@for $i from 1 through 3 { 
  .item-#{$i} { width: 2em * $i; } 
}

Compiled to

.item-1 { 
  width: 2em; 
} 
.item-2 { 
  width: 4em; 
} 
.item-3 { 
  width: 6em; 
}

scss syntax

https://riptutorial.com/

41

@for $i from 1 through 3 { 
  .item-#{$i} { width: 2em * $i; } 
}

compiled to

.item-1 { 
  width: 2em; 
} 
.item-2 { 
  width: 4em; 
} 
.item-3 { 
  width: 6em; 
}

Read SCSS vs Sass online: https://riptutorial.com/sass/topic/2428/scss-vs-sass

https://riptutorial.com/

42

Chapter 14: Update Sass version

Introduction

Update your Sass version using gem / ruby

Examples

Windows

You can check the version of Sass using sass -v

Update all ruby gems gem update

Update only Sass gem update sass

Linux

You can check the version of Sass using sass -v

Update all ruby gems sudo gem update

Update only Sass sudo gem update sass

Read Update Sass version online: https://riptutorial.com/sass/topic/10599/update-sass-version

https://riptutorial.com/

43

Chapter 15: Variables

Syntax

•

$variable_name: value;

Examples

Sass

Variables are used to store a value once which will be used multiple times throughout a Sass 
document.

They are mostly used for controlling things such as fonts and colors but can be used for any value 
of any property.

Sass uses the $ symbol to make something a variable.

$font-stack: Helvetica, sans-serif 
$primary-color: #000000 

body 
  font-family: $font-stack 
  color: $primary-color

SCSS

Just as in Sass, SCSS variables are used to store a value which will be used multiple times 
throughout a SCSS document.

Variables are mostly used to store frequently-used property values (such as fonts and colors), but 
can be used for any value of any property.

SCSS uses the $ symbol to declare a variable.

$font-stack: Helvetica, sans-serif; 
$primary-color: #000000; 

body { 
  font-family: $font-stack; 
  color: $primary-color; 
}

You can use !default when declaring a variable if you want to assign a new value to this variable 
only if it hasn't been assigned yet:

$primary-color: blue; 
$primary-color: red !default; // $primary-color is still "blue" 

https://riptutorial.com/

44

 
 
$primary-color: green;        // And now it's green.

Variable Scope

Variables exist within a specific scope, much like in in JavaScript.

If you declare a variable outside of a block, it can be used throughout the sheet.

$blue: dodgerblue; 

.main { 
    background: $blue; 

    p { 
        background: #ffffff; 
        color: $blue; 
    } 
} 

.header { 
    color: $blue; 
}

If you declare a variable within a block, it can only be used in that block.

.main { 
    $blue: dodgerblue; 

    background: $blue; 

    p { 
        background: #ffffff; 
        color: $blue; 
    } 
} 

.header { 
    color: $blue; // throws a variable not defined error in SASS compiler 
}

Variables declared at the sheet level (outside of a block) can also be used in other sheets if they 
are imported.

Localize Variables with @at-root directive

@at-root directive can be used to localize variables.

$color: blue; 

@at-root { 
  $color: red; 

  .a { 
    color: $color; 

https://riptutorial.com/

45

 
 
 
 
 
 
 
 
  } 
  .b { 
    color: $color; 
  } 
} 

.c { 
  color: $color; 
}

is compiled to:

.a { 
  color: red; 
} 

.b { 
  color: red; 
} 

.c { 
  color: blue; 
}

Interpolation

Variables can be used in string interpolation. This allows you to dynamically generate selectors, 
properties and values. And the syntax for doing so a variable is #{$variable}.

$className: widget; 
$content: 'a widget'; 
$prop: content; 

.#{$className}-class { 
  #{content}: 'This is #{$content}'; 
} 
// Compiles to 

.widget-class { 
  content: "This is a widget"; 
}

You cannot, however use it to dynamically generate names of mixins or functions.

Variables in SCSS

In SCSS variables begin with $ sign, and are set like CSS properties.

$label-color: #eee;

They are only available within nested selectors where they’re defined.

#menu { 
    $basic-color: #eee; 
    color: $basic-color; 

https://riptutorial.com/

46

 
 
 
 
 
}

If they’re defined outside of any nested selectors, then they can be used everywhere.

$width: 5em; 

#menu { 
  width: $width; 
} 

#sidebar { 
  width: $width; 
}

They can also be defined with the !global flag, in which case they’re also available everywhere.

#menu { 
  $width: 5em !global; 
  width: $width; 
} 

#sidebar { 
  width: $width; 
}

It is important to note that variable names can use hyphens and underscores interchangeably. For 
example, if you define a variable called $label-width, you can access it as $label_width, and vice 
versa.

Read Variables online: https://riptutorial.com/sass/topic/2180/variables

https://riptutorial.com/

47

 
 
 
Credits

S. 
No

1

2

3

4

5

6

7

8

9

Chapters

Contributors

Getting started with 
sass

Angelos Chalaris, Benolot, Christopher, Community, Kartik 
Prasad, Rohit Jindal, SamJakob, Stewartside

Compass CSS3 
Mixins

Schlumpf

Convert units

SuperDJ

Extend / Inheritance

Euan Williams, GMchris, user2367593

Functions

Euan Williams, GMchris, Hudson Taylor, Pyloid

Installation

Angelos Chalaris, Pyloid, Stewartside

Loops and Conditons

Akash Kodesia, allejo, Angelos Chalaris, GMchris, 
MMachinegun, ScottL

Mixins

Nesting

Akash Kodesia, Angelos Chalaris, GMchris, Hudson Taylor, 
Ninda, Roxy Walsh

aisflat439, alexbea, Amy, Christopher, Devid Farinelli, GMchris, 
Hudson Taylor, John Slegers, MMachinegun

10 Operators

Angelos Chalaris, Hudson Taylor, Pyloid

11 Partials and Import

Angelos Chalaris, Hudson Taylor, MMachinegun

12 Scss useful mixins

Kindzoku

13 SCSS vs Sass

75th Trombone, Everettss, Jared Hooper, MMachinegun, 
Muzamil301, Pyloid, Robotnicka, Rohit Jindal

14 Update Sass version Schlumpf

15 Variables

Daniyal Basit Khan, evuez, GMchris, Hudson Taylor, jaredsk, 
Pyloid, Stewartside, yassh

https://riptutorial.com/

48