A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://sass-lang.com/documentation/values/strings below:

Sass: Strings

Strings are sequences of characters (specifically Unicode code points). Sass supports two kinds of strings whose internal structure is the same but which are rendered differently: quoted strings, like "Helvetica Neue", and unquoted strings (also known as identifiers), like bold. Together, these cover the different kinds of text that appear in CSS.

EscapesEscapes permalink

All Sass strings support the standard CSS escape codes:

đź’ˇ Fun fact:

For characters that are allowed to appear in strings, writing the Unicode escape produces exactly the same string as writing the character itself.

QuotedQuoted permalink

Quoted strings are written between either single or double quotes, as in "Helvetica Neue". They can contain interpolation, as well as any unescaped character except for:

Quoted strings are guaranteed to be compiled to CSS strings that have the same contents as the original Sass strings. The exact format may vary based on the implementation or configuration—a string containing a double quote may be compiled to "\"" or '"', and a non-ASCII character may or may not be escaped. But that should be parsed the same in any standards-compliant CSS implementation, including all browsers.

đź’ˇ Fun fact:

When a quoted string is injected into another value via interpolation, its quotes are removed! This makes it easy to write strings containing selectors, for example, that can be injected into style rules without adding quotes.

UnquotedUnquoted permalink

Unquoted strings are written as CSS identifiers, following the syntax diagram below. They may include interpolation anywhere.

Railroad diagram copyright © 2018 W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark and permissive document license rules apply. ⚠️ Heads up!

Not all identifiers are parsed as unquoted strings:

Because of this, it’s generally a good idea to write quoted strings unless you’re specifically writing the value of a CSS property that uses unquoted strings.

Escapes in Unquoted StringsEscapes in Unquoted Strings permalink

Compatibility (Normalization):

Dart Sass
since 1.11.0

LibSass
âś—

Ruby Sass
âś—

LibSass, Ruby Sass, and older versions of Dart Sass don’t normalize escapes in identifiers. Instead, the text in the unquoted string is the exact text the user wrote. For example, \1F46D and đź‘­ are not considered equivalent.

When an unquoted string is parsed, the literal text of escapes are parsed as part of the string. For example, \a is parsed as the characters \, a, and space. In order to ensure that unquoted strings that have the same meanings in CSS are parsed the same way, though, these escapes are normalized. For each code point, whether it’s escaped or unescaped:

Other Unquoted StringsOther Unquoted Strings permalink

In addition to identifiers, there are a few unusual corners of CSS syntax that are parsed as unquoted strings. These include:

String IndexesString Indexes permalink

Sass has a number of string functions that take or return numbers, called indexes, that refer to the characters in a string. The index 1 indicates the first character of the string. Note that this is different than many programming languages where indexes start at 0! Sass also makes it easy to refer to the end of a string. The index -1 refers to the last character in a string, -2 refers to the second-to-last, and so on.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4