{"id":338,"date":"2017-11-11T17:04:38","date_gmt":"2017-11-11T11:34:38","guid":{"rendered":"http:\/\/blog.openwebsolutions.in\/?p=338"},"modified":"2017-11-11T17:40:35","modified_gmt":"2017-11-11T12:10:35","slug":"compile-sass-file-css-run-linking-html-pages","status":"publish","type":"post","link":"https:\/\/openwebsolutions.in\/blog\/compile-sass-file-css-run-linking-html-pages\/","title":{"rendered":"Compile a Sass file to Css and run by linking it with Html pages"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><strong>Sass<\/strong> is the most mature, stable, and powerful professional grade CSS extension language in the world. It is a very popular useful css compiler now a days. There are also other css compilers like less etc. but sass has been using from long time. In fact Bootstrap itself have accepted Sass and it have updated its code by using sass in its latest version.<\/p>\n<p>In this blog I am going to explain how to compile a sass (.scss) file to our most familiar css (.css) file.<\/p>\n<p>There are many ways to install sass but I am going to install it in a very simple way.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>For Linux users<\/strong><\/p>\n<p>If you&#8217;re using a distribution of Linux, you&#8217;ll need to install Ruby first. You can install Ruby through the apt package manager, rbenv, or rvm.<\/p>\n<blockquote><p><em>sudo gem install sass &#8211;no-user-install<\/em><\/p>\n<p>&nbsp;<\/p><\/blockquote>\n<p><strong>For Windows users<\/strong><\/p>\n<p>Before you start using Sass you will need to install Ruby. The fastest way to get Ruby on your Windows computer is to use\u00a0<a href=\"http:\/\/rubyinstaller.org\/\">Ruby Installer<\/a>. It&#8217;s a single-click installer that will get everything set up for you super fast.<\/p>\n<p>The installer will also install a Ruby command line powershell application that will let you use the Ruby libraries.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>For Mac users<\/strong><\/p>\n<p>If you prefer the command line over an application then getting Sass set up is a fairly quick process. Sass has a Ruby dependency but if you&#8217;re using a Mac, congratulations, Ruby comes pre-installed.<\/p>\n<p>As I am a windows OS user, going to use windows process.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Step 1<\/strong><\/h4>\n<p>&nbsp;<\/p>\n<p>Go to Ruby Installer @ <em><a href=\"https:\/\/rubyinstaller.org\/\">https:\/\/rubyinstaller.org\/<\/a><\/em> and download the software as per your machine configuration. Mine is windows 32 bit, so I will download and install <em><a href=\"https:\/\/github.com\/oneclick\/rubyinstaller2\/releases\/download\/rubyinstaller-2.4.2-2\/rubyinstaller-2.4.2-2-x86.exe\">Ruby 2.4.2-2 (x86)<\/a><\/em><\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-344\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img1.png\" alt=\"Ruby Installer\" width=\"502\" height=\"536\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img1.png 502w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img1-281x300.png 281w\" sizes=\"(max-width: 502px) 100vw, 502px\" \/><\/p>\n<p>(You can think that what is Ruby Installer, well you will find everything at the above mentioned website link)<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Step 2<\/strong><\/h4>\n<p>&nbsp;<\/p>\n<p><strong>Open your Terminal or Command Prompt.<\/strong><\/p>\n<p>On the Mac the Terminal.app comes installed by default. It&#8217;s located in your &#8220;Utilities&#8221; folder.<\/p>\n<p>On Windows, run `cmd`.<\/p>\n<p><strong>Install Sass.<\/strong><\/p>\n<p>Ruby uses Gems to manage its various packages of code like Sass. In your open terminal window type<\/p>\n<p><em>gem install sass<\/em><\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-346\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img2.png\" alt=\"Install Sass\" width=\"627\" height=\"123\" \/><\/p>\n<p>If you get an error message then it&#8217;s likely you will need to use the\u00a0<em>sudo<\/em>\u00a0command to install the Sass gem. It would look like:<\/p>\n<p><em>sudo gem install sass<\/em><\/p>\n<p>You will get very few lines of installed message in cmd like<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-348\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img3.png\" alt=\"Sass installed successful\" width=\"662\" height=\"331\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img3.png 662w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img3-300x150.png 300w\" sizes=\"(max-width: 662px) 100vw, 662px\" \/><\/p>\n<p>You should now have Sass installed, but it never hurts to double-check. In your terminal \/ cmd application you can type:<\/p>\n<p><em>sass -v<\/em><\/p>\n<p>It will return\u00a0Sass 3.5.3.(Bleeding Edge)<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-349\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img4.png\" alt=\"Sass version\" width=\"665\" height=\"68\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img4.png 665w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img4-300x31.png 300w\" sizes=\"(max-width: 665px) 100vw, 665px\" \/><\/p>\n<p>Congratulations! You&#8217;ve successfully installed Sass on your computer<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Step 3<\/strong><\/h4>\n<p>&nbsp;<\/p>\n<p>Go to the project folder where you want to run the sass via cmd or terminal.<\/p>\n<p>In my case I have a main folder \u201csass\u201d and within this folder a separate folder called \u201ccss\u201d where I want to store all the style sheets. So I will go to css folder using command prompt.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-351\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img5.png\" alt=\"Goto css folder\" width=\"644\" height=\"185\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img5.png 644w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img5-300x86.png 300w\" sizes=\"(max-width: 644px) 100vw, 644px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Step 4<\/strong><\/h4>\n<p>&nbsp;<\/p>\n<p>Now create a index.html file within main folder and create a sass file with .scss extension within css folder manually.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-352\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img6.png\" alt=\"Create necessary folders\" width=\"241\" height=\"100\" \/><\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Step 5<\/strong><\/h4>\n<p>&nbsp;<\/p>\n<p>Go to command prompt and as Sass is installed, you can run<\/p>\n<p><em>sass\u00a0<\/em><em style=\"font-size: 1rem\">input.scss output.css<\/em><span style=\"font-size: 1rem\">\u00a0<\/span><\/p>\n<p>from your cmd or terminal. This means output.css file will be created and the sass file input.scss will compiled to output.css, what ever you will write in sass it will output its results in output.css<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-353\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img7.png\" alt=\"create output file\" width=\"646\" height=\"120\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img7.png 646w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img7-300x56.png 300w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><\/p>\n<p>You can also tell Sass to watch the file and update the CSS every time automaticallly the Sass file changes by watch command<\/p>\n<p><em>sass &#8211;watch input.scss:output.css<\/em><\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-355\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img8.png\" alt=\"Watch scss file if chages\" width=\"644\" height=\"125\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img8.png 644w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img8-300x58.png 300w\" sizes=\"(max-width: 644px) 100vw, 644px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Step 6<\/strong><\/h4>\n<p>&nbsp;<\/p>\n<p>Go to <strong>input.scss<\/strong> file and try to write sass like<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-356\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img9.png\" alt=\"Sass files codes\" width=\"739\" height=\"253\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img9.png 739w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img9-300x103.png 300w\" sizes=\"(max-width: 739px) 100vw, 739px\" \/><\/p>\n<p>Now if you open the newly created output.css file you can see this sass have compiled to css successfully.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-357\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img10.png\" alt=\"css file codes\" width=\"783\" height=\"176\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img10.png 783w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img10-300x67.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img10-768x173.png 768w\" sizes=\"(max-width: 783px) 100vw, 783px\" \/><\/p>\n<p>Along with that you can always see the command prompt have updated automatically and whenever you write sass in sass file and then if you save the file this command prompt text will update.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-358\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img11.png\" alt=\"cmd changes\" width=\"642\" height=\"175\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img11.png 642w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img11-300x82.png 300w\" sizes=\"(max-width: 642px) 100vw, 642px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Step 7<\/strong><\/h4>\n<p>&nbsp;<\/p>\n<p>Open <strong>index.html<\/strong> and link the output.css with the page<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-360\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img12.png\" alt=\"link to html page\" width=\"773\" height=\"221\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img12.png 773w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img12-300x86.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img12-768x220.png 768w\" sizes=\"(max-width: 773px) 100vw, 773px\" \/><\/p>\n<p>Now if we run the index.html in a browser we can see the effects of our style sheet.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-361\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img13.png\" alt=\"sass running in browser\" width=\"835\" height=\"202\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img13.png 835w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img13-300x73.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img13-768x186.png 768w\" sizes=\"(max-width: 835px) 100vw, 835px\" \/><\/p>\n<p>Along with that if we debug \/ inspect the element we can see all the styles are coming from input.scss file<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-363\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/11\/img14.png\" alt=\"Debug\" width=\"610\" height=\"519\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img14.png 610w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/img14-300x255.png 300w\" sizes=\"(max-width: 610px) 100vw, 610px\" \/><\/p>\n<p>That\u2019s it.<\/p>\n<p>This is the way you can create your own styles using sass and run them in all browsers.<\/p>\n<p><strong>Source courtesy<\/strong>: <em><a href=\"http:\/\/sass-lang.com\/\">http:\/\/sass-lang.com\/<\/a><\/em><\/p>\n<p>Please share if you like it!<\/p>\n<p>Follow me on\u00a0<a href=\"https:\/\/www.linkedin.com\/in\/preetam-mallick-84321254\/\"><em><strong>LinkedIn<\/strong><\/em><\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Sass is the most mature, stable, and powerful professional grade CSS extension language in the world. It is a very popular useful css compiler now a days. There are also other css compilers like less etc. but sass has been using from long time. In fact Bootstrap itself have accepted Sass and it have [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":339,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,5],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Compile a Sass file to Css and run by linking it with Html pages - Openweb Solutions Blog<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/openwebsolutions.in\/blog\/compile-sass-file-css-run-linking-html-pages\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Compile a Sass file to Css and run by linking it with Html pages - Openweb Solutions Blog\" \/>\n<meta property=\"og:description\" content=\"&nbsp; Sass is the most mature, stable, and powerful professional grade CSS extension language in the world. It is a very popular useful css compiler now a days. There are also other css compilers like less etc. but sass has been using from long time. In fact Bootstrap itself have accepted Sass and it have [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/openwebsolutions.in\/blog\/compile-sass-file-css-run-linking-html-pages\/\" \/>\n<meta property=\"og:site_name\" content=\"Openweb Solutions Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-11-11T11:34:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-11-11T12:10:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/sass-banner.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"497\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/\",\"name\":\"Openweb Solutions Blog\",\"description\":\"Transforming ideas into reality\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/openwebsolutions.in\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/compile-sass-file-css-run-linking-html-pages\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/11\/sass-banner.jpg\",\"width\":1024,\"height\":497,\"caption\":\"Sass\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/compile-sass-file-css-run-linking-html-pages\/#webpage\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/compile-sass-file-css-run-linking-html-pages\/\",\"name\":\"Compile a Sass file to Css and run by linking it with Html pages - Openweb Solutions Blog\",\"isPartOf\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/compile-sass-file-css-run-linking-html-pages\/#primaryimage\"},\"datePublished\":\"2017-11-11T11:34:38+00:00\",\"dateModified\":\"2017-11-11T12:10:35+00:00\",\"author\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/615090f954d8460cf6186cf920b47398\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/openwebsolutions.in\/blog\/compile-sass-file-css-run-linking-html-pages\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/615090f954d8460cf6186cf920b47398\",\"name\":\"Preetam Mallick\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ed836329485e177373e4ff5323b6670a?s=96&r=g\",\"caption\":\"Preetam Mallick\"},\"description\":\"Frontend developer at Openweb Solutions\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/338"}],"collection":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=338"}],"version-history":[{"count":13,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/338\/revisions"}],"predecessor-version":[{"id":366,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/338\/revisions\/366"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media\/339"}],"wp:attachment":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}