SASS vs CSS

VAIBHAV KUMAR
Catalysts Reachout
Published in
6 min readOct 7, 2022

CSS

What is CSS?

CSS(Cascading Style Sheets) allows you to create great-looking web pages. Using CSS, you can control exactly how HTML elements look in the browser, presenting your markup using whatever design you like.

What is CSS for?

CSS is a language for specifying how documents are presented to users — how they are styled, laid out, etc.
CSS can be used for very basic document text styling — for example, for changing the color and size of headings and links. It can be used to create a layout — for example, turning a single column of text into a layout with a main content area and a sidebar for related information. It can even be used for effects such as animation.

CSS Syntax

CSS is a rule-based language — you define the rules by specifying groups of styles that should be applied to particular elements or groups of elements on your web page.
For example, you can decide to have the main heading on your page to be shown as large red text.

CSS properties have different allowable values, depending on which property is being specified. In our example, we have the color property, which can take various color values. We also have the font-size property. This property can take various size units as a value.
A CSS stylesheet will contain many such rules, written one after the other.

How does CSS actually work?

When a browser displays a document, it must combine the document’s content with its style information. It processes the document in a number of stages, which we’ve listed below. Bear in mind that this is a very simplified version of what happens when a browser loads a webpage and that different browsers will handle the process in different ways.

Advantages of CSS

  1. Consistency: CSS helps to build a consistent structure that web designers can use to construct other pages. Because of this, the web designer’s working efficiency also improves.
  2. Ease of Use: It is very easy to learn CSS and facilitates the creation of websites. All codes are put on one page, meaning it would not involve going through multiple pages to improve or edit the lines.
  3. Website Speed: Typically, the code used by a website may be up to 2 or more pages. But with CSS, that’s not the code, and thus the web site database remains uncluttered, avoiding any website loading problems.
  4. Multiple Browser Support: Many browsers support CSS. It is consistent with all the web browsers on the internet.
  5. Transfer Size: It decreases the size of the file transfer. Therefore, the file transfer is very quick.
  6. Web-Page crawl: CSS helps to allow SEO for the website. Adding CSS to the web pages makes it easier for the search engine to find the website in the search result.

Disadvantages of CSS

  1. Many CSS versions: As opposed to other versions like HTML or JavaScript, CSS has various version such as CSS1, CSS2, CSS2.1, and CSS3.
  2. Fragmentations: There’s a possibility with the CSS that we work with one browser, and we will not be able to work with other web browsers. Thus, web developers need to verify compatibility by running the software through various browsers before the website is set up.
  3. Complications: With the use of third-party tools like Microsoft FrontPage, CSS might become complicated.
  4. Lack of Security: CSS is a system based on open text, so it has no built-in security mechanism that stops it from being overridden. Anyone can alter the CSS file and modify the links by accessing its read and write operations.
  5. Cross-Browser Issues: It is simple to introduce initial CSS changes on a site at the developer’s end. Although the modifications have been made, if the CSS shows identical alteration effects on all browsers, the user will have to confirm compatibility. It is simple because CSS operates on various browsers differently.

SASS

What is SASS?

Sass (which stands for ‘Syntactically awesome style sheets) is an extension of CSS that enables you to use things like variables, nested rules, and inline imports. It also helps to keep things organized and allows you to create style sheets faster. Sass is compatible with all versions of CSS.

What is SASS for?

Stylesheets are getting larger, more complex, and harder to maintain. This is where a CSS pre-processor can help.
Sass lets you use features that do not exist in CSS, like variables, nested rules, mixins, imports, inheritance, built-in functions, and other stuff.

SASS syntax

A browser does not understand Sass code. Therefore, you will need a Sass pre-processor to convert Sass code into standard CSS.
This process is called transpiling. So, you need to give a transpiler (some kind of program) some Sass code and then get some CSS code back.

How does SASS actually work ?

Sass works in such a way that when you write your styles in a .scss file, it gets compiled into a regular CSS file. The CSS code is then loaded into the browser. That is why it’s called a Preprocessor.

Advantages of SASS

  1. It helps users to write clean, quick, and less CSS code in a program structure.
  2. There are fewer codes in it so that we can write CSS faster.
  3. SCSS offers nested so that we can use the nested syntax and useful functions, including color manipulation, math functions, and many other functions.
  4. It consists of variables that help reuse the values as many times as in the CSS.
  5. All versions of CSS are compatible with it. So, we can use any CSS library available.
  6. SASS is versatile with feedback, but any good developer would prefer the inline documentation available in SCSS.

Disadvantages of SASS

  1. Debugging: Pre-processors have a compilation stage that makes the CSS meaningless code lines when attempting to debug the code. But it’s twice as difficult to debug as programming, making it a big disadvantage.
  2. Understanding: Even if the pre-processors have become popular, there is a knowledge gap in CSS.
  3. Large CSS Files: The source files may be tiny, but the CSS produced may be huge.
  4. Loss of benefits: Using SASS can cause the browser’s built-in element inspector to lose its benefits.

CSS vs SASS

Why should we use Sass?

  • Easy to learn: If you are familiar with CSS already, then you’ll be glad to know that Sass actually has a similar syntax, and so you can start using it, even after this tutorial ;)
  • Compatibility: It is compatible with all versions of CSS. So, you can use any available CSS libraries.
  • Saves time: It helps reduce the repetition of CSS, because of its powerful features.
  • Reusable code: Sass allows for variables and chunks of code (mixins) that can be reused over and over again. This helps you save time and makes you able to code faster.
  • Organized Code: Sass helps keep your code organized by using partials.
  • Cross Browser Compatibility: Sass gets compiled into CSS and adds all the necessary vendor prefixes so you don’t have to worry about manually writing them out.

--

--