border:3px solid black;
In the above example, you can set color by saying the color’s name. There is also a wide verity of color name out there also.
And so my question is this. Is there a way to define your own custom color name on your site in css, javascript/jquery, or even php.
Why? (I’m partially mad, but) In c# it can be handy to have a global variable to use that you can change and it would effect everything using it, and I would love a similar effect.
You may ask “Couldn’t you just use class=”myColor”?” I COULD, but I don’t always use the color the same way, I sometimes use it for borders, background, or even text. Also, I’d have to give it a class, rather than declare it in css, which for a border can be weird.
Basically, I was wondering if there’s anything even close to what I am looking for, be it css (so doubt it), jquery, or even php. Considering I want to use this color name in css I doubt this is possible, but I would love to be proven wrong.
You can set variables using a CSS PreProcessor such as SASS or LESS.
Using SASS it looks like this.
Output: