{"id":1400,"date":"2019-03-29T12:14:44","date_gmt":"2019-03-29T06:44:44","guid":{"rendered":"http:\/\/blog.openwebsolutions.in\/?p=1400"},"modified":"2019-03-29T12:14:44","modified_gmt":"2019-03-29T06:44:44","slug":"useful-differences-between-css-and-scss","status":"publish","type":"post","link":"https:\/\/openwebsolutions.in\/blog\/useful-differences-between-css-and-scss\/","title":{"rendered":"Some useful differences between CSS and SCSS"},"content":{"rendered":"<p style=\"text-align: left;\">CSS is the styling language which is used to style web pages.\u00a0Initially, CSS was written to style the HTML pages which grows more and more in the line of codes if the HTML pages increases.<\/p>\n<p style=\"text-align: left;\">As the project gets bigger, maintenance &amp; readability of CSS code gets harder. CSS causes some problems like:<\/p>\n<ul style=\"margin-left: 50px;\">\n<li>Big effort for little changes<\/li>\n<li>Difficulties in structuring the code<\/li>\n<li>Code repetition<\/li>\n<li>Unlimited\u00a0lines of CSS classes &amp; rules<\/li>\n<\/ul>\n<h4 style=\"margin-top: 20px;\"><span style=\"text-decoration: underline;\">CSS Preprocessor<\/span><\/h4>\n<p>A preprocessor helps us to deal with the above problems. It has some advantages over regular CSS. First, define what is a CSS preprocessor?\u00a0A program\/tool that has its own syntax that gets compiled later in standard CSS code.\u00a0A preprocessor has its own syntax to write easier as well as cleaner CSS code. Later, it gets rendered in a separate file to standard CSS, because browsers don\u2019t understand the syntax. There are completely different preprocessors like <em><strong>Sass<\/strong><\/em>, <em><strong>Less<\/strong><\/em>, and <em><strong>Stylus<\/strong><\/em>.<\/p>\n<h5 style=\"margin-top: 20px;\"><span style=\"text-decoration: underline;\">SCSS<\/span><\/h5>\n<p>Sass (Syntactically Awesome Style Sheets) has two syntaxes. The most usually used syntax is understood as \u201cSCSS\u201d (for \u201cSassy CSS\u201d) and is a superset of CSS3\u2019s syntax. This means that every valid CSS3 stylesheet is valid SCSS as well. SCSS files use the extension <em><strong>.scss<\/strong><\/em>.\u00a0SCSS is a special type of file for SASS, a program written in Ruby that assembles CSS style sheets for a browser.\u00a0Using SCSS, we can add much additional functionality such as variables, nesting and more.<\/p>\n<h3><\/h3>\n<h3 style=\"text-align: center;\">Difference between CSS and SCSS<\/h3>\n<h4>Feature #1: Nesting<\/h4>\n<p>Standard CSS doesn\u2019t support nesting. We can\u2019t write a class inside another class. As the project gets bigger, this brings a readability problem and the structure doesn\u2019t look nice.<\/p>\n<h4>Feature #2: Variables<\/h4>\n<p>Like in other programming languages, we can use variables to store values and reuse them later.<\/p>\n<p>&nbsp;<\/p>\n<h5><span style=\"color: #064db8;\">\/* SCSS *\/<\/span><\/h5>\n<pre>$text-color: #f443a5;\r\nbody {\r\ncolor: $text-color;\r\n}<\/pre>\n<h4><\/h4>\n<h4>Feature #3: Mixins<\/h4>\n<p>Mixins are Scss functions that group CSS declarations together. We can repeat them later like variables. We can see some differences in the code below.<\/p>\n<h5>\u00a0 <span style=\"color: #064db8;\">\u00a0\/* SCSS *\/<\/span><\/h5>\n<pre>$pink: #F443a5;\r\n$margin: 20px;\r\n\r\n\r\n.container {\r\nborder-color: $pink;\r\ncolor: darken($pink, 10%);\r\nwidth:300px; \r\nheight:300px;\r\n}\r\n.border {\r\npadding: $margin \/ 2;\r\nmargin: $margin \/ 2;\r\nborder-color: $ pink;\r\n}<\/pre>\n<p>We can see from the CSS below that the SCSS style is a lot more similar to regular CSS.<\/p>\n<h5><span style=\"color: #064db8;\">\/* CSS *\/ <\/span><\/h5>\n<pre>.container {\r\nborder-color: #F443a5;\r\ncolor: #F443a5;\r\n\u00a0\u00a0width:200px; \u00a0\r\n\u00a0\u00a0\u00a0height:200px;\r\n}\r\n.border {\r\npadding: 8px;\r\nmargin: 8px;\r\n\u00a0border-color: #F443a5;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Advantages of using Scss:<\/strong><\/span><\/p>\n<p>The main advantage of using Scss is to save time and make writing CSS easier. You can use variables for unremarkably documented things like color, font-family, margin, etc.<\/p>\n<p><strong>Some handy features Scss provided are:<\/strong><\/p>\n<ol>\n<li><strong>Variables, <\/strong>by which you can\u00a0store reusable values with variables, this can be handy to store values like color hex code or a font stack.<\/li>\n<li><strong>Nesting,<\/strong> just write it in nests just like what we do with HTML elements.\u00a0CSS rules can be nested within each other.<\/li>\n<li><strong>Partials,<\/strong> we can write our stylesheet in a modular way using partials and import statements.<\/li>\n<li><strong>Mixins,<\/strong> In SCSS we can shorten the code using a\u00a0@mixin\u00a0so we don\u2019t have to write\u00a0properties repeatedly.<\/li>\n<li><strong>Extension and Inheritance,<\/strong>\u00a0an easy way to derive the same properties of another selector.<\/li>\n<li><strong>Mathematical Operators,<\/strong> allows us to do math using operators. We can perform straightforward calculations within our code for higher output.<!--more--><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>CSS is the styling language which is used to style web pages.\u00a0Initially, CSS was written to style the HTML pages which grows more and more in the line of codes if the HTML pages increases. As the project gets bigger, maintenance &amp; readability of CSS code gets harder. CSS causes some problems like: Big effort [&hellip;]<\/p>\n","protected":false},"author":31,"featured_media":1401,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18,5],"tags":[112,107],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Some useful differences between CSS and SCSS<\/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\/useful-differences-between-css-and-scss\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Some useful differences between CSS and SCSS\" \/>\n<meta property=\"og:description\" content=\"CSS is the styling language which is used to style web pages.\u00a0Initially, CSS was written to style the HTML pages which grows more and more in the line of codes if the HTML pages increases. As the project gets bigger, maintenance &amp; readability of CSS code gets harder. CSS causes some problems like: Big effort [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/openwebsolutions.in\/blog\/useful-differences-between-css-and-scss\/\" \/>\n<meta property=\"og:site_name\" content=\"Openweb Solutions Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-29T06:44:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/03\/css.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\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\/useful-differences-between-css-and-scss\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/03\/css.jpg\",\"width\":1000,\"height\":667,\"caption\":\"css vs scss\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/useful-differences-between-css-and-scss\/#webpage\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/useful-differences-between-css-and-scss\/\",\"name\":\"Some useful differences between CSS and SCSS\",\"isPartOf\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/useful-differences-between-css-and-scss\/#primaryimage\"},\"datePublished\":\"2019-03-29T06:44:44+00:00\",\"dateModified\":\"2019-03-29T06:44:44+00:00\",\"author\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/78cc69c3015b9c840d74591261861e22\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/openwebsolutions.in\/blog\/useful-differences-between-css-and-scss\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/78cc69c3015b9c840d74591261861e22\",\"name\":\"Munmun Das\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/033db0a0941d27e1e3e3bdc05f2e1189?s=96&r=g\",\"caption\":\"Munmun Das\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1400"}],"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\/31"}],"replies":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=1400"}],"version-history":[{"count":25,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1400\/revisions"}],"predecessor-version":[{"id":1482,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/1400\/revisions\/1482"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media\/1401"}],"wp:attachment":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=1400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=1400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=1400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}