There's alsoyoucancallitcustomproperties, butthat's notasexcitingCSSvariables, especiallyfordevelopersanddesignersouttherewhoarefamiliarwithvariablesinlanguageslikePHPor J Query, orevenusingCSSpreprocessorlanguageslikesassandlessand S C.
S s whereyouusevariables.
Itreallyextendswth e functionalityofCSSorwhateverprogramminglanguageyou'reusingthatareusingthevariables.
Let's startoffbyselectingthesesandboxclassandwithintheirwhatwe'regoingtodoisdeclarethreedifferentvariablesorcustomproperties, andthewaythisworkswithcustompropertiesinCSSiswhenyoudefinethatspecificcustompropertywithin a selector, itisitsscopeisthatselector.
Soifyouwantedthethesevariablestobeaccessibleacrosstheentirewebsiteandallstylesyouwoulduse a selectorlikebodyorsomethinglikerouteisanotherselectorthroughelementof a treerepresentingthedocument.
Youcanusethoseelectorsifyouwantthesespecificvariablestobeaccessiblethroughouttheentiredocumentsomethinglike a colororfontsizeormaybebrandingspecificallybrandingcolors.
Butwe'rejustgoingtouseinthiscasesandbox.
Soallofthevariablesareitsscope.
Isthisselectorsothevariableswon't workif I amtryingtousethosevariablesonelementsoutsideofsandbox.
Now, if I savethatandthengoovertothebrowser, you'regonnaseethatyoucannotseethetext, andthat's becauseitisthesamecolorasthebackgroundinthiscaseorprettycloseandit's centered.
Soweknowthatthatvariableisworking.
Let's continueandstylethebackground, andwe'regoingtosaveouropenclosingvariableorbar a doubledashprimarydashcolorandlet's goaheadandsayMarginandwhat's therewegoand I'm gonnasaveour.
Thisone's gonnabebasedashmeasurement, which, asweknow, is 20 pixels.
Let's wrapthisinCalcuttaandthensemiColonandwe'regonnacalculatethis, Butthenweactuallyhavetoperform a calculationsooutsideofthis s sothisisthefirstargumenthereandthere's onemoretimeswe'regoingtotimes 10.
We'vegotourorangeredboxnumberoneandherhotpinkboxnumbertwoThecolorsandthemeasurementsarecalculatedandcreatedusingcustomproperties, alsoknownas C.
S s variables.
Thatisexciting.
I hopethatshedsomelightandsomeinsightonsomecoolthingsthatyoucoulddowithCSSvariablesinsteadofhavingtogoinandcreatenewinstallpreprocessorsanddifferentCSSlanguageslikesass, unlessforcertainprojectsthatmightnotbethatnecessaryortoomuch.
Ah, work.
Maybejust a simplelandingpageandyoujustwanttogetsomethingupquickly.