Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope of variables #3964

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/guide/CSS.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,15 @@ Let's say we define a variable `$success: lime;`.
Our `$border` variable could then be updated to `$border: wide $success;`, which will
be translated to `$border: wide lime;`.

### Variable Scope:

It's essential to note that CSS variables have a global scope within the file where they are defined. This means that variables can be accessed and utilized throughout the entire stylesheet. However, variables defined in one file cannot be directly accessed in another file in the same project.

If you define a series of variables in one file, these variables will be accessible within that file and can be used later in that same file. However, if you wish to share variables across multiple files, you may need to consider alternative methods such as importing those variables into each file where they are required.

This scoping behavior ensures encapsulation and prevents unintended conflicts between variables in different parts of your project.


## Initial value

All CSS rules support a special value called `initial`, which will reset a value back to its default.
Expand Down