{"id":369435,"date":"2023-03-03T05:38:49","date_gmt":"2023-03-03T05:38:49","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=369435"},"modified":"2026-02-04T09:41:52","modified_gmt":"2026-02-04T09:41:52","slug":"use-sass-in-wordpress","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/","title":{"rendered":"Sass in WordPress: A Step-By-Step Guide"},"content":{"rendered":"\n<p>In this blog article, we will learn how to use Sass in WordPress for new users and beginners.<\/p>\n\n\n\n<p>Sass and other CSS preprocessors are powerful tools that help designers and developers write less code while achieving more. In the end, all preprocessed code is compiled into standard CSS.<\/p>\n\n\n\n<p>SCSS offers advanced features like variables for cleaner, more maintainable, and minified code. It supports all CSS capabilities and adds powerful features that go beyond traditional CSS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Prerequisites<\/strong><\/h2>\n\n\n\n<p>This tutorial assumes that you have a working knowledge of setting up a WordPress environment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Getting Started<\/h2>\n\n\n\n<p>CSS is easy to learn, but large stylesheets can become hard to manage. <\/p>\n\n\n\n<p>Changing a single value, like a color across the site, often means finding and updating it everywhere, which can quickly turn into a nightmare.<\/p>\n\n\n\n<p>Sass, a CSS preprocessor, removes repetitive work by generating reusable style blocks. <\/p>\n\n\n\n<p>It speeds up development, improves readability, and adds features like variables, nesting, mixins, and inheritance.<\/p>\n\n\n\n<p>When migrating an old CSS project to Sass, you can split large stylesheets into clean, organized modules. Using partials, variables, and mixins makes the code easier to manage and maintain.<\/p>\n\n\n\n<p>Follow the process I mentioned below:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using the SASS compiler<\/h2>\n\n\n\n<p>There are a number of ways (applications)you can compile your SASS to CSS, some of which are paid apps and some of which are free. It depends on which one you want to use. Some paid app includes<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/codekitapp.com\/\">CodeKit<\/a>&nbsp;(Paid) Mac<\/li>\n\n\n\n<li><a href=\"http:\/\/hammerformac.com\/\">Hammer<\/a>&nbsp;(Paid) Mac<\/li>\n\n\n\n<li><a href=\"http:\/\/livereload.com\/\">LiveReload<\/a>&nbsp;(Paid, Open&nbsp;Source) Mac&nbsp;Windows<\/li>\n\n\n\n<li><a href=\"https:\/\/prepros.io\/\">Prepros<\/a>&nbsp;(Paid) Mac&nbsp;Windows Linux<\/li>\n\n\n\n<li><a href=\"http:\/\/scout-app.io\/\">Scout-App<\/a>&nbsp;(Free, Open&nbsp;Source) Windows&nbsp;Linux Mac<\/li>\n<\/ul>\n\n\n\n<p>Others include using grunt, gulp. I prefer using gulp.\u00a0<a href=\"https:\/\/gulpjs.com\/\">Here is the link<\/a>\u00a0where you can find all the details about how to get started with a gulp.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Gulp?<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">gulp is a toolkit for automating painful or time-consuming tasks in your development workflow, so you can stop messing around and build something.<\/pre>\n\n\n\n<p>This perfectly describes what Gulp really is. Install it in a few easy steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install&nbsp;<a href=\"https:\/\/nodejs.org\/en\/\">Node.js<\/a>.<\/li>\n\n\n\n<li>Install Gulp globally: <mark class=\"has-inline-color has-vivid-red-color\">npm install gulp-cli -g<\/mark><\/li>\n\n\n\n<li>Make a theme folder with: <mark class=\"has-inline-color has-vivid-red-color\">mkdir themeName<\/mark> and enter the folder with cd themeName.<\/li>\n\n\n\n<li>Initialize your project with npm: <mark class=\"has-inline-color has-vivid-red-color\">npm init<\/mark><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Install Node.js<\/h2>\n\n\n\n<p><a href=\"https:\/\/gulpjs.com\/\">Gulp<\/a>\u00a0requires you to download and install <a href=\"https:\/\/lorepirri.com\/nodejs.org\/download\/\">Node.js<\/a>, which will also install\u00a0<a href=\"https:\/\/www.npmjs.com\/\">NPM<\/a>, which is its package manager, and it is used to install modules.<\/p>\n\n\n\n<p>To verify that you have installed&nbsp;<a href=\"https:\/\/lorepirri.com\/nodejs.org\/download\/\">Node.js<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/www.npmjs.com\/\">NPM<\/a>&nbsp;correctly, open the terminal and check their current version by entering the commands:&nbsp;<code>node -v<\/code>&nbsp;and&nbsp;<code>npm -v<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install Gulp globally<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you\u2019ve previously installed gulp globally, run&nbsp;<code>npm rm --global gulp<\/code>&nbsp;before following these instructions.<\/li>\n\n\n\n<li>Install the gulp command line utility, run: <mark class=\"has-inline-color has-vivid-red-color\">npm install &#8211;global gulp-cli.<\/mark><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Initialize Gulp In Project Directory<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a theme folder in wp-content\/theme<\/li>\n\n\n\n<li>Use the <mark class=\"has-inline-color has-vivid-red-color\">npm init<\/mark> command for initialization. The<\/li>\n\n\n\n<li><mark class=\"has-inline-color has-vivid-red-color\">npm init<\/mark> command will create a package.json file<\/li>\n\n\n\n<li>After the Creation of package.json, you need to set up the gulp dependencies<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"># Setup Gulp Dependencies<\/h2>\n\n\n\n<p>run the following npm command to install Gulp and all plug-ins as development dependencies:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-black-color has-luminous-vivid-amber-background-color has-text-color has-background\" style=\"font-size:18px\">npm install --save-dev autoprefixer browser-sync css-mqpacker cssnano gulp-concat gulp-deporder gulp-imagemin gulp-newer gulp-postcss gulp-sass gulp-strip-debug gulp-uglify gulp-noop postcss-assets<\/pre>\n\n\n\n<p>This will create a <code>node_modules<\/code> A folder that contains the module code with dependencies. For Git users, add\u00a0<code>node_modules<\/code>\u00a0to your\u00a0<code>.gitignore<\/code>\u00a0file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"># Create Gulp Configuration File<\/h2>\n\n\n\n<p>Create a new&nbsp;<code>gulpfile.js<\/code>&nbsp;the configuration file in your project folder<\/p>\n\n\n\n<p>edit the file&nbsp;<code>gulpfile.js<\/code>&nbsp;in your&nbsp;<code>project source folder<\/code>, replace its content, if any, with these contents:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Gulp.js configuration\n'use strict';\n\nconst\n\n  \/\/ ** change these two to yours **\n  wordpress_project_name = 'your-site',\n  theme_name = 'your-site',\n  browserSyncProxy = 'http:\/\/local.your-site.test\/',\n\n  \/\/ source and build folders, ** change this to yours **\n  dir = {\n    src         : 'src\/',\n    build       : `..\/..\/vagrant-local\/www\/${wordpress_project_name}\/public_html\/wp-content\/themes\/${theme_name}\/`\n  },\n\n  \/\/ Gulp and plugins\n  { src, dest, series, parallel, watch } = require('gulp'),\n  noop          = require(\"gulp-noop\"),\n  newer         = require('gulp-newer'),\n  imagemin      = require('gulp-imagemin'),\n  sass          = require('gulp-sass'),\n  postcss       = require('gulp-postcss'),\n  deporder      = require('gulp-deporder'),\n  concat        = require('gulp-concat'),\n  stripdebug    = require('gulp-strip-debug'),\n  uglify        = require('gulp-uglify'),\n  browserSync   = require('browser-sync').create(),\n  log           = require('fancy-log')\n;\n\n\/\/ For BrowserSync\nconst reload = (cb) =&gt; { browserSync.reload(); cb(); };<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">#Image Processing<\/h2>\n\n\n\n<p>Image files can often be compressed further using tools such as&nbsp;<a href=\"https:\/\/github.com\/imagemin\/imagemin\">imagemin<\/a>. Add the following code to&nbsp;<code>gulpfile.js<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ image settings\nconst images = {\n  src         : dir.src + 'images\/**\/*',\n  build       : dir.build + 'images\/'\n};\n\/\/ image processing\ngulp.task('images', () =&gt; {\n  return gulp.src(images.src)\n    .pipe(newer(images.build))\n    .pipe(imagemin())\n    .pipe(gulp.dest(images.build));\n});<\/pre>\n\n\n\n<p>Save then run&nbsp;<code><mark class=\"has-inline-color has-vivid-red-color\">gulp images<\/mark><\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"># Sass Compilation<\/h2>\n\n\n\n<p>WordPress cannot use Sass files directly; you must compile to a single&nbsp;<code>style.css<\/code>&nbsp;file. Add the following code to&nbsp;<code>gulpfile.js<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ CSS settings\nvar css = {\n  src         : dir.src + 'scss\/style.scss',\n  watch       : dir.src + 'scss\/**\/*',\n  build       : dir.build,\n  sassOpts: {\n    outputStyle     : 'nested',\n    imagePath       : images.build,\n    precision       : 3,\n    errLogToConsole : true\n  },\n  processors: [\n    require('postcss-assets')({\n      loadPaths: ['images\/'],\n      basePath: dir.build,\n      baseUrl: '\/wp-content\/themes\/wptheme\/'\n    }),\n    require('autoprefixer')({\n      browsers: ['last 2 versions', '&gt; 2%']\n    }),\n    require('css-mqpacker'),\n    require('cssnano')\n  ]\n};\n\/\/ CSS processing\ngulp.task('css', ['images'], () =&gt; {\n  return gulp.src(css.src)\n    .pipe(sass(css.sassOpts))\n    .pipe(postcss(css.processors))\n    .pipe(gulp.dest(css.build))\n    .pipe(browsersync ? browsersync.reload({ stream: true }) : gutil.noop());\n});<\/pre>\n\n\n\n<p>Launch this new task with&nbsp;<code><mark class=\"has-inline-color has-vivid-red-color\">gulp css<\/mark><\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"># JavaScript Processing<\/h2>\n\n\n\n<p>Add the following code to&nbsp;<code>gulpfile.js<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ JavaScript settings\nconst js = {\n  src         : dir.src + 'js\/**\/*',\n  build       : dir.build + 'js\/',\n  filename    : 'scripts.js'\n};\n\/\/ JavaScript processing\ngulp.task('js', () =&gt; {\n\n  return gulp.src(js.src)\n    .pipe(deporder())\n    .pipe(concat(js.filename))\n    .pipe(stripdebug())\n    .pipe(uglify())\n    .pipe(gulp.dest(js.build))\n    .pipe(browsersync ? browsersync.reload({ stream: true }) : gutil.noop());\n});<\/pre>\n\n\n\n<p>Run this new task with&nbsp;<code><mark class=\"has-inline-color has-vivid-red-color\">gulp js<\/mark><\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">#&nbsp;Run Everything<\/h2>\n\n\n\n<p>Rather than calling each task separately, we can add the following code to&nbsp;<code>gulpfile.js<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ run all tasks\ngulp.task('build', ['css', 'js']);<\/pre>\n\n\n\n<p>You can now use\u00a0<code><mark class=\"has-inline-color has-vivid-red-color\">gulp build<\/mark><\/code>\u00a0to run the\u00a0\u00a0<code>js<\/code>,\u00a0<code>css<\/code>\u00a0and\u00a0<code>images<\/code>\u00a0tasks in parallel. (Note\u00a0<code>images<\/code>\u00a0is a dependency of the\u00a0<code>css<\/code>\u00a0task, as we set it up early, so we need not call it directly.)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"># Enable File Watching And Browsersync<\/h2>\n\n\n\n<p>Your workflow can be radically improved by:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Letting Gulp watch for file changes before launching the appropriate task.<\/li>\n\n\n\n<li>Automatically reloading CSS and JavaScript files when they change (without a page refresh).<\/li>\n\n\n\n<li>Automatically refreshing the page when a template file changes.<\/li>\n<\/ol>\n\n\n\n<p>First, we need to define a\u00a0<code>browsersync<\/code>\u00a0task in\u00a0<code>gulpfile.js<\/code>. <\/p>\n\n\n\n<p>This will create a proxy server to your web server running WordPress on\u00a0<code>localhost<\/code>\u00a0(Change this domain or use an IP address as necessary):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Browsersync options\nconst syncOpts = {\n  proxy       : 'localhost',\n  files       : dir.build + '**\/*',\n  open        : false,\n  notify      : false,\n  ghostMode   : false,\n  ui: {\n    port: 8001\n  }\n};\n\/\/ browser-sync\ngulp.task('browsersync', () =&gt; {\n  if (browsersync === false) {\n    browsersync = require('browser-sync').create();\n    browsersync.init(syncOpts);\n  }\n});<\/pre>\n\n\n\n<p>Now add a\u00a0<code>watch<\/code>\u00a0The task to run Browsersync, watch for file changes, and run the appropriate task:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ watch for file changes\ngulp.task('watch', ['browsersync'], () =&gt; {\n\n  \/\/ image changes\n  gulp.watch(images.src, ['images']);\n\n    \/\/ CSS changes\n  gulp.watch(css.watch, ['css']);\n\n  \/\/ JavaScript main changes\n  gulp.watch(js.src, ['js']);\n});<\/pre>\n\n\n\n<p>Finally, add a\u00a0<code>default<\/code>\u00a0Gulp task, which runs an initial build and starts the\u00a0<code>watch<\/code>\u00a0task:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ default task\ngulp.task('default', ['build', 'watch']);<\/pre>\n\n\n\n<p>Now run&nbsp;<code>gulp<\/code>&nbsp;from the command line. The console will display output which includes lines similar to:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[BS] Proxying: http:\/\/localhost\n[BS] Access URLs:\n -------------------------------------\n       Local: http:\/\/localhost:3000\n    External: http:\/\/192.168.15.194\/:3000\n -------------------------------------\n          UI: http:\/\/localhost:8001\n UI External: http:\/\/192.168.15.194\/:8001\n -------------------------------------\n[BS] Watching files...<\/pre>\n\n\n\n<p>Your WordPress site will load as before, but Gulp will watch for changes and apply the updates immediately. You\u2019ll never need to switch to your browser and click refresh again!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Let\u2019s write some Sass<\/h2>\n\n\n\n<p>Now that we are all configured, we are ready to write some Sass.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites in Sass<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Basic understanding of HTML &amp; CSS<\/li>\n\n\n\n<li>A code editor (VS Code recommended). If you don&#8217;t have it installed, download it&nbsp;<a href=\"http:\/\/code.visualstudio.com\/\">here<\/a>.<\/li>\n\n\n\n<li>And a browser (Chrome or Firefox recommended)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What exactly is Sass?<\/h2>\n\n\n\n<p>Sass (Syntactically Awesome Style Sheets) is a CSS preprocessor that gives your CSS superpowers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What additions does SASS bring to CSS?<\/h2>\n\n\n\n<p>These are the features Sass adds to CSS to make your work easier:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Variables<\/li>\n\n\n\n<li>Nested rules<\/li>\n\n\n\n<li>Partials<\/li>\n\n\n\n<li>Modules<\/li>\n\n\n\n<li>Mixins<\/li>\n\n\n\n<li>Extends\/inheritance<\/li>\n\n\n\n<li>Operators<\/li>\n<\/ul>\n\n\n\n<p>These are the additions through which makes your work easier. We\u2019ll discuss each feature in more detail below:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Variables in <mark>Sass<\/mark><\/h3>\n\n\n\n<p>One key Sass feature in WordPress is variables, letting you define and reuse values across stylesheets. This simple tool greatly improves consistency and speeds up your overall workflow.<\/p>\n\n\n\n<p>So, let&#8217;s say you want to use the same color, font, or any other CSS value throughout your coding. <\/p>\n\n\n\n<p>Just store it in a variable and reuse it whenever you want. Remember that SASS uses the $symbol for variables. <\/p>\n\n\n\n<p>Here&#8217;s an example of variable usage in Sass vs CSS:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ CSS\nbody {\n  background: #ccc;\n  color: #333;\n}\n\n\/\/ SCSS\n\n$backgroud-color:#ccc;\n$primary-color: #333;\n \nbody {\n  background: $backgroud-color;\n  color: $primary-color;\n}\n<\/pre>\n\n\n\n<p>With Sass, you define variables like <code>$background-color<\/code> and <code>$primary-color<\/code> Once and reuse them everywhere. <\/p>\n\n\n\n<p>This is especially useful for brand colors, saving time and avoiding repetitive value updates.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Nested rules in Sass<\/h3>\n\n\n\n<p>Sass also comes in handy when you need to make your code more readable. With Sass, you can nest your CSS selectors in the same way as you can in HTML. <\/p>\n\n\n\n<p>Here\u2019s an example of nesting used in SASS:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ CSS\n\nnav ul {\n  margin: 0;\n  padding: 0;\n  list-style: none;\n}\nnav li {\n  display: inline-block;\n}\nnav a {\n  display: block;\n  padding: 6px 12px;\n  text-decoration: none;\n}\n\n\/\/ SCSS\n\nnav {\n  ul {\n    margin: 0;\n    padding: 0;\n    list-style: none;\n  }\n \n  li { display: inline-block; }\n \n  a {\n    display: block;\n    padding: 6px 12px;\n    text-decoration: none;\n  }\n}\n<\/pre>\n\n\n\n<p>As you can see, the ul, li, and a selectors are nested inside the nav selector, which makes your CSS code more organized, cleaner, and easier to read.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Partials in <mark>Sass<\/mark><\/h3>\n\n\n\n<p>You have the ability to create partial Sass files that have small snippets of CSS that you can later include in other Sass files.<\/p>\n\n\n\n<p>You can use the partial Sass file by using the underscore\u00a0<strong>_partial.css<\/strong>\u00a0in the name of your file<\/p>\n\n\n\n<p>The underscore tells Sass the file is a partial and shouldn\u2019t compile into its own CSS file. These partials are included using the <code><strong>@import<\/strong><\/code> or <code><strong>@use<\/strong><\/code> rules.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sass\/\n|\n|\u2013 abstracts\/\n|   |\u2013 _variables.scss    # Sass Variables\n|   |\u2013 _functions.scss    # Sass Functions\n|   |\u2013 _mixins.scss       # Sass Mixins\n|   |\u2013 _placeholders.scss # Sass Placeholders\n|\n|\u2013 base\/\n|   |\u2013 _reset.scss        # Reset\/normalize\n|   |\u2013 _typography.scss   # Typography rules\n|   \u2026                     # Etc.\n|\n|\u2013 components\/\n|   |\u2013 _buttons.scss      # Buttons\n|   |\u2013 _carousel.scss     # Carousel\n|   |\u2013 _cover.scss        # Cover\n|   |\u2013 _dropdown.scss     # Dropdown\n|   \u2026                     # Etc.\n|\n|\u2013 layout\/\n|   |\u2013 _navigation.scss   # Navigation\n|   |\u2013 _grid.scss         # Grid system\n|   |\u2013 _header.scss       # Header\n|   |\u2013 _footer.scss       # Footer\n|   |\u2013 _sidebar.scss      # Sidebar\n|   |\u2013 _forms.scss        # Forms\n|   \u2026                     # Etc.\n|\n|\u2013 pages\/\n|   |\u2013 _home.scss         # Home specific styles\n|   |\u2013 _contact.scss      # Contact specific styles\n|   \u2026                     # Etc.\n|\n|\u2013 themes\/\n|   |\u2013 _theme.scss        # Default theme\n|   |\u2013 _admin.scss        # Admin theme\n|   \u2026                     # Etc.\n|\n`\u2013 main.scss              # Main Sass file\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Modules in <mark>Sass<\/mark><\/h3>\n\n\n\n<p>Now, when you split your Sass into separate parts with the @use rule, it will start loading the file as a module. <\/p>\n\n\n\n<p>That is, you can refer to its variables, functions, and mixins in your files using a namespace based on your file&#8217;s name. The file you use will also include the generated CSS in its output.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/Sass\n\n\/\/ _base.scss\n$background-color: #ddd;\n$primary-color: #333;\n  \nbody {\n  background: $background-color;\n  color: $primary-color;\n}\n  \n\/\/ styles.scss\n@use 'base';\n  \n.inverse {\n  background-color: base.$primary-color;\n  color: white;\n}\n  \n  \n\/\/ CSS\nbody {\n  font: 100% Helvetica, sans-serif;\n  color: #333;\n}\n  \n.inverse {\n  background-color: #333;\n  color: white;\n}\n<\/pre>\n\n\n\n<p>As you can see, this makes your workflow more organized as you can define variables in separate files and then import them into a different Sass file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Mixins in <mark>Sass<\/mark><\/h3>\n\n\n\n<p>Mixins are a powerful Sass feature that reduces repetitive CSS by letting you reuse groups of declarations. <\/p>\n\n\n\n<p>They also accept values for flexibility, making them ideal for tasks like handling vendor prefixes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Sass\n@mixin transform($property) {\n  -webkit-transform: $property;\n  -ms-transform: $property;\n  transform: $property;\n}\n.box { @include transform(rotate(30deg)); }\n  \n\/\/ CSS \n.box {\n  -webkit-transform: rotate(30deg);\n  -ms-transform: rotate(30deg);\n  transform: rotate(30deg);\n}\n<\/pre>\n\n\n\n<p>To create a mixin, use the <code>@mixin<\/code> directive and give it a name, such as <code>transform<\/code>. <\/p>\n\n\n\n<p>You can pass values using variables like <code>$property<\/code>, allowing the mixin to handle transforms or any other input flexibly.<\/p>\n\n\n\n<p>Once your mixin is created, you can use it as a CSS declaration that starts with @include and then is followed by the name of the mixin.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Extends\/Inheritance in <mark>Sass<\/mark><\/h3>\n\n\n\n<p>Finally, one of the most useful features of Sass is the&nbsp;<strong>@extend<\/strong>. This feature helps you share a group of CSS properties of one selector with another.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Operators in Sass<\/h3>\n\n\n\n<p>Operators in Sass let you perform math directly in your stylesheets using <code>+<\/code>, <code>-<\/code>, <code>*<\/code>, <code>\/<\/code>, and <code>%<\/code>. This makes tasks like calculating widths for elements such as aside and article simple and efficient.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ SCSS SYNTAX\n.container {\n  width: 100%;\n}\n \narticle[role=\"main\"] {\n  float: left;\n  width: 600px \/ 960px * 100%;\n}\n \naside[role=\"complementary\"] {\n  float: right;\n  width: 300px \/ 960px * 100%;\n}\n  \n\/\/ CSS OUTPUT\n.container {\n  width: 100%;\n}\n \narticle[role=\"main\"] {\n  float: left;\n  width: 62.5%;\n}\n \naside[role=\"complementary\"] {\n  float: right;\n  width: 31.25%;\n}\n<\/pre>\n\n\n\n<p>In this example, we\u2019ve made a simple fluid grid which is based on 960 px. With operations in Sass, we convert pixel values to percentages without too much of a hassle.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>If you\u2019re new to This, give it a try and explore the guide at <a href=\"https:\/\/sass-lang.com\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Sass Doc<\/a> for a quick start. If you can write CSS, you already have the skills to write Sass.<\/p>\n\n\n\n<p>Hopefully, this tutorial brings anyone using Sass a better understanding of how to combine it with WordPress and helps you build or edit your theme more efficiently than ever before.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog article, we will learn how to use Sass in WordPress for new users and beginners. Sass and other CSS preprocessors are powerful tools that help designers and developers write less code while achieving more. In the end, all preprocessed code is compiled into standard CSS. SCSS offers advanced features like variables for <a href=\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":500,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-369435","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Sass in WordPress: A Step-By-Step Guide - Webkul Blog<\/title>\n<meta name=\"description\" content=\"Professional developers use Sass for scalable code, faster prototyping, and cleaner workflows. Learn variables, mixins &amp; functions today.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sass in WordPress: A Step-By-Step Guide - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Professional developers use Sass for scalable code, faster prototyping, and cleaner workflows. Learn variables, mixins &amp; functions today.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-03T05:38:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-04T09:41:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Nitesh Rai\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nitesh Rai\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/\"},\"author\":{\"name\":\"Nitesh Rai\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/78f26883482f64bfc5332b10ae732538\"},\"headline\":\"Sass in WordPress: A Step-By-Step Guide\",\"datePublished\":\"2023-03-03T05:38:49+00:00\",\"dateModified\":\"2026-02-04T09:41:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/\"},\"wordCount\":1532,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/\",\"url\":\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/\",\"name\":\"Sass in WordPress: A Step-By-Step Guide - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2023-03-03T05:38:49+00:00\",\"dateModified\":\"2026-02-04T09:41:52+00:00\",\"description\":\"Professional developers use Sass for scalable code, faster prototyping, and cleaner workflows. Learn variables, mixins & functions today.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Sass in WordPress: A Step-By-Step Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/78f26883482f64bfc5332b10ae732538\",\"name\":\"Nitesh Rai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/77a8fc6875aecab89af2dfafc1faa8aba9a6492f3742d5c4d7120f2ef9442857?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/77a8fc6875aecab89af2dfafc1faa8aba9a6492f3742d5c4d7120f2ef9442857?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Nitesh Rai\"},\"description\":\"Nitesh Rai is an experienced developer that specialises in Vue JS, REST APIs, and Git. He specialises in WooCommerce API Development and IoT Development Services, creating seamless and innovative solutions that help businesses flourish. Nitesh's technological abilities enable high-quality, customised service delivery.\",\"url\":\"https:\/\/webkul.com\/blog\/author\/nitesh-rai769\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Sass in WordPress: A Step-By-Step Guide - Webkul Blog","description":"Professional developers use Sass for scalable code, faster prototyping, and cleaner workflows. Learn variables, mixins & functions today.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"Sass in WordPress: A Step-By-Step Guide - Webkul Blog","og_description":"Professional developers use Sass for scalable code, faster prototyping, and cleaner workflows. Learn variables, mixins & functions today.","og_url":"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2023-03-03T05:38:49+00:00","article_modified_time":"2026-02-04T09:41:52+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Nitesh Rai","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Nitesh Rai","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/"},"author":{"name":"Nitesh Rai","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/78f26883482f64bfc5332b10ae732538"},"headline":"Sass in WordPress: A Step-By-Step Guide","datePublished":"2023-03-03T05:38:49+00:00","dateModified":"2026-02-04T09:41:52+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/"},"wordCount":1532,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/","url":"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/","name":"Sass in WordPress: A Step-By-Step Guide - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2023-03-03T05:38:49+00:00","dateModified":"2026-02-04T09:41:52+00:00","description":"Professional developers use Sass for scalable code, faster prototyping, and cleaner workflows. Learn variables, mixins & functions today.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/use-sass-in-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Sass in WordPress: A Step-By-Step Guide"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/78f26883482f64bfc5332b10ae732538","name":"Nitesh Rai","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/77a8fc6875aecab89af2dfafc1faa8aba9a6492f3742d5c4d7120f2ef9442857?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/77a8fc6875aecab89af2dfafc1faa8aba9a6492f3742d5c4d7120f2ef9442857?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Nitesh Rai"},"description":"Nitesh Rai is an experienced developer that specialises in Vue JS, REST APIs, and Git. He specialises in WooCommerce API Development and IoT Development Services, creating seamless and innovative solutions that help businesses flourish. Nitesh's technological abilities enable high-quality, customised service delivery.","url":"https:\/\/webkul.com\/blog\/author\/nitesh-rai769\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/369435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/500"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=369435"}],"version-history":[{"count":57,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/369435\/revisions"}],"predecessor-version":[{"id":524852,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/369435\/revisions\/524852"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=369435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=369435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=369435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}