CINXE.COM
Sass: Request for Comments: Indented Syntax Improvements
<!doctype html> <html lang="en" class="no-js"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="description" content="Syntactically Awesome Style Sheets" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Sass: Request for Comments: Indented Syntax Improvements</title> <link rel="alternate" type="application/atom+xml" href="/feed.xml" /> <link rel="apple-touch-icon" sizes="152x152" type="image/png" href="/icon.png"> <link rel="icon" type="image/png" sizes="152x152" href="/icon.png"> <link rel="icon" type="image/x-icon" href="/favicon.ico" /> <link href="https://fonts.googleapis.com/css?family=Source+Code+Pro::ital,wght@0,400;0,600;1,400|Source+Sans+Pro:300,400,600|Source+Serif+Pro" media="screen" rel="stylesheet" /> <link href="https://cdn.jsdelivr.net/npm/@docsearch/css@alpha" media="screen" rel="stylesheet" /> <link href="/assets/dist/css/sass.css" media="screen" rel="stylesheet" /> <noscript> <link href="/assets/dist/css/noscript.css" media="screen" rel="stylesheet" /> </noscript> <!-- Google Analytics (https://developers.google.com/analytics/devguides/collection/gtagjs). --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-535380-14"></script> <script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', 'UA-535380-14'); </script> </head><body data-layout="body" class="blog 044-rfc-indented-syntax"> <!--[if lt IE 9]> <p class="browserupgrade"> You are using an <strong>outdated</strong> browser. Please <a href="https://browsehappy.com/">upgrade your browser</a> to improve your experience and security. </p> <![endif]--> <header class="sl-r-banner" itemtype="https://schema.org/WPHeader" itemscope="itemscope" role="banner"> <div class="sl-c-alert" style="--sl-background--alert: black"> <div class="sl-l-container"> <p><strong>Free Palestine</strong></p> </div> </div> <div class="sl-c-pop-stripe"></div> <div class="sl-l-container"> <div class="sl-l-grid sl-l-grid--full sl-l-large-grid--fit sl-l-large-grid--center sl-l-large-grid--gutters"> <p class="sl-l-grid__column sl-r-banner__brand"> <a href="/"><img height="48" alt="Sass" src="/assets/img/logos/logo.svg"></a> </p> <nav class="sl-r-banner__navigation sl-l-grid__column sl-l-large-grid sl-l-large-grid__column--auto-size sl-c-list-horizontal-wrapper" itemtype="https://schema.org/SiteNavigationElement" itemscope="itemscope" role="navigation" aria-label="Site navigation"> <ul> <li><a href="/playground">Playground</a></li> <li><a href="/install">Install</a></li> <li><a href="/guide">Learn Sass</a></li> <li><a href="/blog">Blog</a></li> <li><a href="/documentation">Documentation</a></li> <li><a href="/community">Get Involved</a></li> <li> <div id="docsearch"></div> </li> </ul> </nav> </div> </div> </header> <main class="content" id="main-content" itemprop="mainContentOfPage" role="main"> <h1 class="sl-l-container">Request for Comments: Indented Syntax<span class="widont"> </span>Improvements</h1> <div class="sl-l-container sl-color--white-background sl-l-section"> <p class="sl-c-attribution">Posted 3 December 2024 by James Stuckey<span class="widont"> </span>Weber</p> <div class="sl-l-container sl-l-container--small"> <p>For users of the indented syntax (<code>.sass</code>), there has been a long standing request for the ability to have line breaks that don’t end a statement. Certain <span class="caps">CSS</span> syntaxes like <code>grid-template</code> and <code>@font-face</code> <code>src</code> declarations are long, and line breaks can greatly increase the readability of the<span class="widont"> </span>styles.</p> <p>There have been many suggestions, several attempts, and numerous workarounds to address this pain point. We are proposing several new syntax options in the indented syntax that add considerable flexibility and look to address this as part of the<span class="widont"> </span>language.</p> <h2 id="multiline-statements" tabindex="-1">Multiline statements<a class="anchor" href="#multiline-statements"><span class="visuallyhidden">Multiline statements permalink</span></a></h2> <p>We propose allowing statements in the indented syntax to span multiple lines, as long as line breaks occur in places where the statement can’t<span class="widont"> </span>end.</p> <p>A common way of using this syntax will be wrapping lists with line breaks in parentheses. This allows for a grid-template declaration on multiple<span class="widont"> </span>lines.</p> <pre class="language-sass"><code class="language-sass"><span class="token selector">.grid</span> <span class="token property-line"> <span class="token property">display</span><span class="token punctuation">:</span> grid</span> <span class="token property-line"> <span class="token property">grid-template</span><span class="token punctuation">:</span> (</span> <span class="token string">"header"</span> min-content <span class="token string">"main"</span> 1fr <span class="token selector">)</span></code></pre> <p>As usual, these parentheses will not be included in the<span class="widont"> </span>output.</p> <pre class="language-css"><code class="language-css"><span class="token selector">.grid</span> <span class="token punctuation">{</span> <span class="token property">display</span><span class="token punctuation">:</span> grid<span class="token punctuation">;</span> <span class="token property">grid-template</span><span class="token punctuation">:</span> <span class="token string">"header"</span> min-content <span class="token string">"main"</span> 1fr<span class="token punctuation">;</span> <span class="token punctuation">}</span></code></pre> <p>Powering this change is the underlying rule that linebreaks only end statements where it’s valid for a statement to end. Anywhere where a statement can’t end, a linebreak is ignored. This means that if the parser can’t tell whether or not a linebreak is intended to end a statement, it will end the<span class="widont"> </span>statement.</p> <p>This example demonstrates several places where line breaks will not end<span class="widont"> </span>statements.</p> <pre class="language-sass"><code class="language-sass"><span class="token atrule-line"><span class="token atrule">@each</span> $item in /* A statement can't end after the word "in" in an `<span class="token atrule">@each</span>` statement. */</span> <span class="token selector">1, 2, 3</span> <span class="token selector">.item-#{ </span> <span class="token variable-line"> <span class="token variable">$item</span> <span class="token operator">/</span><span class="token operator">*</span> A statement can't end inside the curly braces in an interpolation. <span class="token operator">*</span><span class="token operator">/</span></span> <span class="token selector">}</span> <span class="token property-line"> <span class="token property">content</span><span class="token punctuation">:</span> <span class="token variable">$item</span> <span class="token operator">*</span> <span class="token operator">/</span><span class="token operator">*</span> A statement can't end after a multiplication operator. <span class="token operator">*</span><span class="token operator">/</span></span> <span class="token selector">10</span></code></pre> <p>As a counter example, here are some places in the same stylesheet where linebreaks could end statements. These linebreaks will cause compilation errors because the <em>next</em> line is not able to be<span class="widont"> </span>parsed.</p> <blockquote> <p><strong>Important! This code snippet demonstrates what will <span class="caps">NOT</span><span class="widont"> </span>work.</strong></p> </blockquote> <pre class="language-sass"><code class="language-sass"><span class="token atrule-line"><span class="token atrule">@each</span> $item in 1, /* A statement can end after a value, even in the middle of a list. */</span> <span class="token selector">2, 3</span> <span class="token selector">.item-#{ $item }</span> <span class="token property-line"> <span class="token property">content</span><span class="token punctuation">:</span> <span class="token variable">$item</span> <span class="token operator">/</span><span class="token operator">*</span> A statement can end after a value, <span class="token operator">and</span> does <span class="token operator">not</span> look ahead for operators. <span class="token operator">*</span><span class="token operator">/</span></span> <span class="token selector">* 10</span></code></pre> <h2 id="semicolons-are-also-allowed" tabindex="-1">Semicolons are also allowed<a class="anchor" href="#semicolons-are-also-allowed"><span class="visuallyhidden">Semicolons are also allowed<span class="widont"> </span>permalink</span></a></h2> <p>Another proposed change would allow semicolons to optionally be added at the end of statements in the indented syntax. Indentation rules still apply, so you won’t be able to separate multiple statements on the same line, even with a<span class="widont"> </span>semicolon.</p> <h2 id="no-breaking-changes" tabindex="-1">No breaking changes<a class="anchor" href="#no-breaking-changes"><span class="visuallyhidden">No breaking changes<span class="widont"> </span>permalink</span></a></h2> <p>These changes are opt-in, and authors who don’t want to use the new syntax do not have to. No changes need to be made to existing stylesheets written in the indented<span class="widont"> </span>syntax.</p> <h2 id="an-update-to-the-proposal" tabindex="-1">An update to the proposal<a class="anchor" href="#an-update-to-the-proposal"><span class="visuallyhidden">An update to the proposal<span class="widont"> </span>permalink</span></a></h2> <p>An earlier version of this post proposed a "<span class="caps">SCSS</span>-in-Sass" format. After feedback from tool maintainers, this has been removed from the proposal, but we welcome feedback on the <a href="https://github.com/sass/sass/issues/4003">Github<span class="widont"> </span>issue</a>.</p> <h2 id="next-steps" tabindex="-1">Next steps<a class="anchor" href="#next-steps"><span class="visuallyhidden">Next steps permalink</span></a></h2> <p>This is still in the proposal phase, and we are open to feedback. Review the proposal <a href="https://github.com/sass/sass/blob/main/proposal/indented-syntax-improvements.md">on Github</a>, and <a href="https://github.com/sass/sass/issues/new">open an issue</a> with any thoughts or concerns you may<span class="widont"> </span>have.</p> <p>In addition to feedback from authors using the indented syntax, we are also interested in hearing from maintainers of tooling that supports the indented<span class="widont"> </span>syntax.</p> </div> </div> <div class="sl-c-alert"> <div class="sl-l-container sl-c-list-horizontal-wrapper" aria-labelledby="release-nav"> <ul class="sl-l-grid--justify-center"> <li id="release-nav">Current Releases:</li> <li><span class="release-name"><a href="/dart-sass">Dart Sass</a> <a href="https://github.com/sass/dart-sass/releases/tag/1.85.0">1.85.0</a></span></li> <li><span class="release-name"><a href="/libsass">LibSass</a> <a href="https://github.com/sass/libsass/releases/tag/3.6.6">3.6.6</a></span></li> <li><span class="release-name"><a href="/ruby-sass">Ruby Sass</a> <span aria-label="coffin" role="presentation">⚰</span></span></li> <li class="sl-l-grid__column sl-l-large-grid__column--auto-size"><a href="/implementation">Implementation Guide</a></li> </ul> </div> </div> </main> <footer class="site-footer contentinfo" itemtype="https://schema.org/WPFooter" itemscope="itemscope" role="contentinfo"> <div class="sl-l-container"> <div class="sl-l-grid sl-l-grid--full sl-l-large-grid--fit sl-l-large-grid--center sl-l-large-grid--gutters"> <div class="sl-l-grid__column"> <p>Sass © 2006–2025 the Sass team, and numerous contributors. It is available for use and modification under the <a href="https://github.com/sass/dart-sass/blob/main/LICENSE"><span class="caps">MIT</span><span class="widont"> </span>License</a>.</p> <nav class="sl-c-list-horizontal-wrapper sl-c-list-wrap"> <ul> <li><a href="https://github.com/sass">Sass on GitHub</a></li> <li><a href="https://github.com/sass/sass-site">Website Source Code</a></li> <li><a href="/styleguide">Style Guide</a></li> <li><a href="/community-guidelines">Community Guidelines</a></li> </ul> </nav> </div> <div class="sl-l-grid__column sl-l-large-grid__column--auto-size sl-l-large-grid--justify-right sl-c-footer-link-grid"> <a class="sl-c-button sl-c-button--icon sl-c-button--icon-text" href="https://front-end.social/@sass"><svg width="20" height="20" viewBox="0 0 61 65" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M60.7539 14.3904C59.8143 7.40642 53.7273 1.90257 46.5117 0.836066C45.2943 0.655854 40.6819 0 29.9973 0H29.9175C19.2299 0 16.937 0.655854 15.7196 0.836066C8.70488 1.87302 2.29885 6.81852 0.744617 13.8852C-0.00294988 17.3654 -0.0827298 21.2237 0.0561464 24.7629C0.254119 29.8384 0.292531 34.905 0.753482 39.9598C1.07215 43.3175 1.62806 46.6484 2.41704 49.9276C3.89445 55.9839 9.87499 61.0239 15.7344 63.0801C22.0077 65.2244 28.7542 65.5804 35.2184 64.1082C35.9295 63.9428 36.6318 63.7508 37.3252 63.5321C38.8971 63.0329 40.738 62.4745 42.0913 61.4937C42.1099 61.4799 42.1251 61.4621 42.1358 61.4417C42.1466 61.4212 42.1526 61.3986 42.1534 61.3755V56.4773C42.153 56.4557 42.1479 56.4345 42.1383 56.4151C42.1287 56.3958 42.1149 56.3788 42.0979 56.3655C42.0809 56.3522 42.0611 56.3429 42.04 56.3382C42.019 56.3335 41.9971 56.3336 41.9761 56.3384C37.8345 57.3276 33.5905 57.8234 29.3324 57.8156C22.0045 57.8156 20.0336 54.3384 19.4693 52.8908C19.0156 51.6397 18.7275 50.3346 18.6124 49.0088C18.6112 48.9866 18.6153 48.9643 18.6243 48.9439C18.6333 48.9236 18.647 48.9056 18.6643 48.8915C18.6816 48.8774 18.7019 48.8675 18.7237 48.8628C18.7455 48.858 18.7681 48.8585 18.7897 48.8641C22.8622 49.8465 27.037 50.3423 31.2265 50.3412C32.234 50.3412 33.2387 50.3412 34.2463 50.3146C38.4598 50.1964 42.9009 49.9808 47.0465 49.1713C47.1499 49.1506 47.2534 49.1329 47.342 49.1063C53.881 47.8507 60.1038 43.9097 60.7362 33.9301C60.7598 33.5372 60.8189 29.8148 60.8189 29.4071C60.8218 28.0215 61.2651 19.5781 60.7539 14.3904Z" fill="url(#paint0_linear_89_8)" /> <path d="M50.3943 22.237V39.5876H43.5185V22.7481C43.5185 19.2029 42.0411 17.3949 39.036 17.3949C35.7325 17.3949 34.0778 19.5338 34.0778 23.7585V32.9759H27.2434V23.7585C27.2434 19.5338 25.5857 17.3949 22.2822 17.3949C19.2949 17.3949 17.8027 19.2029 17.8027 22.7481V39.5876H10.9298V22.237C10.9298 18.6918 11.835 15.8754 13.6453 13.7877C15.5128 11.7049 17.9623 10.6355 21.0028 10.6355C24.522 10.6355 27.1813 11.9885 28.9542 14.6917L30.665 17.5633L32.3788 14.6917C34.1517 11.9885 36.811 10.6355 40.3243 10.6355C43.3619 10.6355 45.8114 11.7049 47.6847 13.7877C49.4931 15.8734 50.3963 18.6899 50.3943 22.237Z" fill="white" /> <defs> <linearGradient id="paint0_linear_89_8" x1="30.5" y1="0" x2="30.5" y2="65" gradientUnits="userSpaceOnUse" > <stop stop-color="#6364FF" /> <stop offset="1" stop-color="#563ACC" /> </linearGradient> </defs> </svg> @sass@front-end.social </a> <a class="sl-image-link" href="https://www.netlify.com"><img alt="Deploys by Netlify" src="https://www.netlify.com/v3/img/components/netlify-color-bg.svg"/></a> </div> </div> </div> </footer> <script src="https://cdn.jsdelivr.net/npm/@docsearch/js@alpha"></script> <script> docsearch({ container: '#docsearch', appId: 'Q9MULQONSV', indexName: 'sass-lang', apiKey: '2ebc7881b79986f58dc2f424769bf3fc', transformItems: function(hits) { var domain = window.location.origin + "/"; hits.forEach(function(hit) { if (! hit.url.startsWith(domain)) { hit.url = hit.url.replace(/^https?:\/\/[^\/]+\//, domain); } }); return hits; } }); </script> <script src="/assets/dist/js/sass.js"></script> <!-- Current page: /blog/rfc-indented-syntax/ --> </body> </html>