<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Akanksha Sharma on Medium]]></title>
        <description><![CDATA[Stories by Akanksha Sharma on Medium]]></description>
        <link>https://medium.com/@akanksha.s9560?source=rss-9cb7fdc40e26------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gwAMgXqY2_jemEHTcsF2jw.png</url>
            <title>Stories by Akanksha Sharma on Medium</title>
            <link>https://medium.com/@akanksha.s9560?source=rss-9cb7fdc40e26------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 08:08:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akanksha.s9560/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Beginner’s guide to SASS]]></title>
            <link>https://medium.com/@akanksha.s9560/practical-guide-to-sass-9a749001ec84?source=rss-9cb7fdc40e26------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a749001ec84</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[sass]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Akanksha Sharma]]></dc:creator>
            <pubDate>Thu, 12 Apr 2018 07:26:01 GMT</pubDate>
            <atom:updated>2018-04-12T08:30:38.127Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s face it, writing css is messy. More so when reviewing the code which other people have written. I find SASS is the answer to that. It helps you to write clean code which is readable.</p><p>Let’s jump into it. Let’s create a simple HTML which has nested div’s , hover, focus, repeated CSS properties, you know standard HTML we face in daily life.</p><blockquote>It is important to understand why are we using classses <strong>parent1__link1</strong>. It is a part of BEM (Block Element Modifier) methodology where <strong>parent1 </strong>is block and <strong>link1 </strong>is element. BEM follows <strong>simple </strong>rules to name and organise your CSS and gives everyone on a project a declarative syntax which they can use so that they’re on the same page.</blockquote><blockquote>You can read about it <a href="http://getbem.com/">here</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*zanUCVgJsz7WDMu1wq00YA.jpeg" /><figcaption>Example HTML Markup</figcaption></figure><h3>Variables</h3><p>Let’s start with writing css for header. Pretty simple stuff, background-color and color properties.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VU4eN80-fTIESW6IDJsNCw.jpeg" /><figcaption>CSS for header class</figcaption></figure><p>Here with help of SASS we can change <strong><em>color codes to variable </em></strong>so that it can be reused . So, let’s create variables for our color codes (you can use <a href="http://www.color-blindness.com/color-name-hue/">this </a>to come up with names for color variables) using <strong><em>$ (this is important to create variables in SASS). </em></strong>Our new css for header would look like this. We can also use variable for many things padding, margins, color basically anything you want to reuse.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*ZOfjSD9byucKBwzAK6ZTAw.jpeg" /><figcaption>Use variable for reusable properties</figcaption></figure><h3>Imports</h3><p>To make css even more modular, SASS provides import functionality. We can put all the color names, mixins, common styles in different files and import them. So, let’s create a <em>_color.scss</em> file.</p><blockquote>Note the name of<strong> _color.scss</strong> file. This is called a <strong>partial file</strong> meaning this file contains little snippets of CSS that you can include in other Sass files. The <strong>underscore </strong>lets SASS know that the file is only a partial file and that it should not be generated into a CSS file</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FdoOFhPo6WFLgJKVrrQE6Q.jpeg" /><figcaption>_color.scss file</figcaption></figure><p>And we can import this file in our main scss file. using command</p><blockquote><em>@import ‘./_color.scss’</em></blockquote><p>and continue using color variables same way as depicted above.</p><h3>Nesting</h3><p>Next we jump to <strong><em>parent1 </em></strong><em>(please refer HTML Markup above)</em>and it’s children.</p><h4><strong>Problem statement 1</strong>: Write CSS for <strong><em>parent1 </em></strong>and <strong><em>parent1__link1</em></strong></h4><p>For the this problem, we will use <strong><em>&amp; </em></strong>for concatenation of classes <strong><em>parent1</em></strong> and <strong><em>parent1__link1</em></strong>. Please refer to image below (pay attention to use of variables here as well)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nm2tjjwx9BfSQGRp7lwagw.jpeg" /></figure><h4><strong>Problem statement 2</strong>: Write <strong><em>hover </em></strong>and <strong><em>after </em></strong>classes for &lt;a&gt; element</h4><p>For this problem we will concatenate pseudo classes and elements to <strong>parent1__link1 </strong>using<strong> &amp;</strong>.</p><blockquote>Make a note: pseudo classes are concatenated using <strong><em>&amp;:</em></strong> and pseudo elements are concatenated with <strong><em>&amp;::</em></strong></blockquote><p>Comprehensive list of pseudo classes and pseudo link is available <a href="http://www.growingwiththeweb.com/2012/08/pseudo-classes-vs-pseudo-elements.html">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*H7oc3zJlyvc39-oUAHp2HA.jpeg" /><figcaption>Use of Pseudo classes in SASS</figcaption></figure><h3>Mixins</h3><p>As described above we have written CSS for parent1. We will write same CSS for parent two as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oU7OU3td-wXpAebfSxQc5Q.jpeg" /><figcaption>complete css file with styles for parent1 and parent2</figcaption></figure><p>As we can see in above file, parent1 and parent2 share many common css properties. We could make this css cleaner, simpler and more readable using <em>MIXINS. </em>Here is how mixin works:</p><p>We create a custom common style using <strong><em>@mixin</em></strong> keyword like depicted in image below. It contains all the property that is common to both parent1 and parent2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fcGfQnkhC5CFpFsd9AS9UQ.jpeg" /><figcaption>Mixin for common style of parent</figcaption></figure><p>Next, we include the mixin in our parent styles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jGmb-5lw_Nfc4XQBRJ3Djw.jpeg" /><figcaption>Usage of Mixins</figcaption></figure><p>Here, I have created mixin for both <em>link style</em> and <em>parent style</em>. It makes code much more cleaner and readable.</p><p>This is a basic guide to get started with SASS. Of course, SASS provides great variety of functionalities that can be used to make your life easier when writing CSS. You can refer to full guide for SASS <a href="https://sass-lang.com/guide">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a749001ec84" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>