Reputation: 75
Whenever I try to compile Sass code to CSS with either the terminal or the program Koala I get this error message:
Error: Invalid CSS after "body ": expected selector, was "{"
on line 5 of style.sass
Use --trace for backtrace
Here's the piece of code the error seems to be referring to:
body {
background {
color: $background-color
}
}
How can I fix my code to make it compile correctly?
Upvotes: 1
Views: 1685
Reputation: 693
background must be class name or id or simply background css property.
body {
.background {
color: $background-color;
}
}
body {
#background {
color: $background-color;
}
}
body {
background : $background-color;
}
Upvotes: 0
Reputation: 1386
Sass, unlike Scss, uses indentation instead of curly braces.
body {
background {
color: $background-color;
}
}
becomes
body
background
color: $background-color
Though, I'm quite sure you mean to have background
as a property instead of a selector.
body
background-color: $background-color
Upvotes: 0
Reputation: 11
You cloud try adding a colon after background
.
body {
background: {
color: $background-color;
}
}
Upvotes: 0
Reputation: 13678
The way your selector reads is that it is looking for the <body>
element, and then a <background>
element (which isn't a thing that exists in HTML, to my knowledge), and then you are setting the text inside that element to the color
in your var $background-color
. I think either one of two things:
Either you meant for background
to be a class or id, like .background
, in which case your code becomes:
body {
.background {
color: $background-color;
}
}
Or, more likely, you are very tired and just got your wires crossed, and mean to be setting the background-color
property like this:
body {
background-color: $background-color;
}
Please note that you were also missing an ending semi-colon, which I added.
Upvotes: 1