Home >Web Front-end >CSS Tutorial >Why Is My Sass File Throwing an 'Invalid CSS: Expected Expression' Error?

Why Is My Sass File Throwing an 'Invalid CSS: Expected Expression' Error?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-09 22:45:02413browse

Why Is My Sass File Throwing an

Troubleshooting "Invalid CSS: Expected Expression" Error in Sass

Problem: Despite having valid CSS code, the Sass file fails to compile, with an error stating "expected expression (e.g. 1px, bold), was ';'".

Explanation:

The error occurs because the Sass file is not properly named. Sass uses the .sass extension for its syntax, while Scss (an extension of Sass) uses the .scss extension. The error message indicates that the file is being parsed as Sass, which expects a different syntax.

Solution:

Change the file extension to .scss to compile it as a Scss file:

#navbar {
  width: 80%; // Semicolon removed
  height: 23px;
}

By using the correct extension, the file will be interpreted with the appropriate syntax, resolving the "expected expression" error.

The above is the detailed content of Why Is My Sass File Throwing an 'Invalid CSS: Expected Expression' Error?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn