1

Here is the example

main.css mobo.css

styleguide.css (Where all CSS variables are mentioned)

Can I use them in main.css and mobo.css ???

1

2 Answers 2

2

"CSS variables" is the colloquial name for Custom Properties.

Like any other property, it doesn't matter where it is set from¹, only that it applies to the element. Therefore it doesn't matter which stylesheet sets the properties or which one reads it.

<style>
  #foo {
    background: var(--example);
    height: 35px;
  }
</style>

<style>
  #foo {
    --example: red;
  }
</style>


<div id="foo">
</div>


Footnotes

  1. If multiple sources try to set the same property then it might start to matter since document order is one of the decision points when calculating the cascade order.
Sign up to request clarification or add additional context in comments.

Comments

0

Yes, just link your file with all the variables in the HTML

<link rel="stylesheet" href="var.css">

Or if you are using SASS, in your main css file you can do :

@import('file.css');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.