<?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 Claytonsiby on Medium]]></title>
        <description><![CDATA[Stories by Claytonsiby on Medium]]></description>
        <link>https://medium.com/@claytonsiby?source=rss-d57a1d965bee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6JThF2wPIybSg_oKVwmcrg.png</url>
            <title>Stories by Claytonsiby on Medium</title>
            <link>https://medium.com/@claytonsiby?source=rss-d57a1d965bee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:11:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@claytonsiby/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[The Power of a CSS Pre-Processor.]]></title>
            <link>https://medium.com/@claytonsiby/the-power-of-a-css-pre-processor-6d72b2ff156a?source=rss-d57a1d965bee------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d72b2ff156a</guid>
            <dc:creator><![CDATA[Claytonsiby]]></dc:creator>
            <pubDate>Thu, 25 Jun 2020 18:59:46 GMT</pubDate>
            <atom:updated>2020-06-25T18:59:46.391Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*Ixs0EQ-NFYUGwOT7cmcjKA.jpeg" /></figure><p>Being a great programmer requires you to write good, readable &amp; clean code. Sometimes as a developer, you may be working on a multi-paged website that requires a bunch of styles for each of the pages. Trying to come up with meaningful selectors for the different sections on each page becomes tedious &amp; time-consuming hence making it difficult to write clean and maintainable code, this is where a preprocessor can help to style the pages independently without having to worry about selectors or creating different CSS files. Here we are going to talk about the Syntactically Awesome Stylesheets ( Sass ).</p><p>SASS is a CSS preprocessor that reduces the repetition of CSS and it also saves time &amp; comes with nifty goodies that make writing CSS fun again. You write sass code &amp; the preprocessor compile it to standard CSS that can be used for your website. SASS makes use of features like Variables, Mixins, Inheritance, Functions, Nesting &amp; Partials. Here we will discuss the most used features variables, nesting &amp; partials. If you would like to get learn more about the other features, check out <a href="https://sass-lang.com/guide">https://sass-lang.com/guide</a>.</p><h3>To install and Get sass running on your machine:</h3><p>You can install Sass on Windows, Mac, or Linux by downloading the package for your operating system <a href="https://github.com/sass/dart-sass/releases/tag/1.26.9">from GitHub</a> and <a href="https://katiek2.github.io/path-doc/">adding it to your</a> Path.</p><p>Or if you use node.js, you can also install Sass using npm by running:</p><pre>npm install -g sass</pre><p>Once Sass is installed, you can compile your Sass to CSS using the sass command. You will also need to tell Sass which file to build from &amp; which file to output the CSS to. For example:</p><pre>sass --watch input.scss output.css</pre><p>Will create a single sass file input.scss and compile into standard CSS output.css</p><p>Note the Sass file used in this example uses the.scss extension. There is also the .sass extension that can be used for a sass file, but we will mainly focus on the .scss instead.</p><h4>Using Variables</h4><p>Let’s start by changing the color of an element using variables.</p><p>HTML</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;link rel=&quot;stylesheet&quot; href=&quot;mystyle.css&quot;&gt;<br>&lt;body&gt;<br><br>&lt;div&gt;</pre><pre>&lt;p&gt;This is a paragraph.&lt;/p&gt;</pre><pre>&lt;/div&gt;<br><br><br><br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>CSS</p><pre>div p {<br>  color: red;<br>}</pre><p>We can do the same thing in a clean maintainable way using Sass Variables which are a way to store information that you can re-use later. You initialize/define a variable using the $ sign. Let’s see a variable in action below:</p><pre>$myColor: red;<br><br>div p {<br>  color: $myColor;<br>}</pre><p>From the above example, $myColor: red; is a variable used to store a color value, we can use the variable name $myColor whenever we want to apply red color to any element on the site.</p><h4>Nesting</h4><p>Nesting is a clean way to refer to an HTML element without worrying about a selector name for that particular element. Let’s have a look at how we can nest the paragraph ( p ) inside of the div .</p><pre>$myColor: red;<br><br>div {</pre><pre>  p {<br>   color: $myColor; <br>  }</pre><pre>}</pre><h4>Partials</h4><p>A partial is a Sass file named with a leading underscore (<em>e.g</em> <em>_partial.scss), the underscore flag tells SASS that this is a partial &amp; it shouldn’t be generated into a CSS file</em>. Partials help modularize your stylesheet files keeping your code clean &amp; easy to maintain. A partial is more like a subset of the big CSS file, you can import it in the <strong>main.scss </strong>file<strong> or other partials. </strong>You can have a partial that carries styles for a single page, let’s say you are working on a website that consists of the home, about &amp; tickets page. Your SASS folder would more like this:</p><pre>stylesheets <br>     sass<br>       partials  <br>          _home.scss<br>          _about.scss<br>           _ticket.scss<br>       main.scss</pre><p>An explanation for the above example, the <strong><em>stylesheets</em></strong><em>, </em>is a folder that holds all the stylesheet files including the <strong><em>sass</em></strong> folder which encapsulate the <strong><em>partials</em></strong> folder. Inside the partials folder, we have the three different partials/modules (<em> _home.scss, _about.scss &amp; _tickets.scss</em> ) in which we style the three pages independently.</p><p>For all these partials to be compiled into a single CSS file, they need to be imported inside of the <strong><em>main.scss</em></strong> file which regenerates Sass code to regular CSS.</p><p>Here is how you import a partial using the <strong><em>@import</em></strong> rule:</p><pre><strong>main.scss</strong></pre><pre> @import &#39;partials/home&#39;;<br> @import &#39;partials/about&#39;;<br> @import &#39;partials/tickets&#39;;</pre><p>Note that when importing the partial files, we do not use the <strong><em>.scss</em></strong> extension or the <strong><em>underscore</em></strong> that&#39;s because Sass knows that you’re importing a partial that is inside the same folder as the <strong><em>main.scss</em></strong> file.</p><p><strong>CONCLUSION</strong></p><p>With all having been said, Sass will save you a lot of headaches, a lot of time, once you are up and running.</p><p>For more information visit <a href="https://sass-lang.com/">https://sass-lang.com/</a> &amp; learn more about the Sass Preprocessor.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d72b2ff156a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>