{"id":1099,"date":"2022-01-23T10:46:06","date_gmt":"2022-01-23T10:46:06","guid":{"rendered":"https:\/\/mobileaders.com\/?p=1099"},"modified":"2022-01-23T23:10:36","modified_gmt":"2022-01-23T23:10:36","slug":"what-you-need-to-know-about-css-variables","status":"publish","type":"post","link":"https:\/\/mobileaders.com\/?p=1099","title":{"rendered":"What You Need To Know About CSS Variables ?"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1gvGL4Djch1UA52y0NgkD_g-1024x576.jpeg\" alt=\"\" class=\"wp-image-1100\" srcset=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1gvGL4Djch1UA52y0NgkD_g-1024x576.jpeg 1024w, https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1gvGL4Djch1UA52y0NgkD_g-300x169.jpeg 300w, https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1gvGL4Djch1UA52y0NgkD_g-768x432.jpeg 768w, https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1gvGL4Djch1UA52y0NgkD_g.jpeg 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-left has-black-color has-white-background-color has-text-color has-background has-normal-font-size\"><strong>CSS variables<\/strong> are entities defined by CSS authors that contain specific values to be reused throughout a document. They are set using custom property notation, Variables follow the same scope and inheritance rules like any other CSS definition. The easiest way to use them, is to make them globally available, by adding the declarations to the <code><strong>:root<\/strong><\/code> pseudo-class, so that all other selectors can inherit it.<\/p>\n\n\n\n<pre class=\"wp-block-code has-normal-font-size\" style=\"background:linear-gradient(135deg,rgb(238,238,238) 100%,rgb(169,184,195) 100%)\"><code>:root{<br>    --awesome-blue: #f6f69;<br>}<\/code><\/pre>\n\n\n\n<p class=\"has-normal-font-size\">To access the value inside a variable we can use the <code><strong>var(...)<\/strong><\/code> syntax. Note that names are case sensitive, so <strong><code>--foo != --FOO<\/code>.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-normal-font-size\" style=\"background:linear-gradient(135deg,rgb(238,238,238) 100%,rgb(169,184,195) 100%)\"><code>.some-element{\n    background-color: var(--awesome-blue);\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Support<\/strong><\/h2>\n\n\n\n<p class=\"has-normal-font-size\" id=\"d73f\">The history of CSS variables is a bit spotty. Originally spec\u2019d out by the W3C in 2012, the feature was initially implemented by only Chrome and Firefox. When the specification was updated in 2014 with a significant syntax improvement, Firefox kept up and modified its implementation, while Chrome decided to back-burner implementation efforts until things settled down. For its part, Microsoft sort of whistled and looked the other way.<\/p>\n\n\n\n<p class=\"has-black-color has-text-color has-normal-font-size\" id=\"bf8d\">As late as September of 2015, <a href=\"http:\/\/www.caniuse.com\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>caniuse<\/strong><\/a><strong>.<\/strong><a href=\"http:\/\/www.caniuse.com\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>com<\/strong><\/a> reported browser support for CSS variables at less than 9%, as seen in the upper-right corner of this report.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1xag8BlDLwV68PYiuYv3xHg.png\" alt=\"\" class=\"wp-image-1101\" width=\"778\" height=\"280\" srcset=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1xag8BlDLwV68PYiuYv3xHg.png 700w, https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1xag8BlDLwV68PYiuYv3xHg-300x108.png 300w\" sizes=\"auto, (max-width: 778px) 100vw, 778px\" \/><\/figure>\n\n\n\n<p class=\"has-normal-font-size\">However, in 2016, Chrome, Safari, Opera, and Android browser all jumped on the variables train, and suddenly support soared to 69%! (That\u2019s global support; US-only support is 77%.)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1sJAA97yn6wyZHugPaD6wWw.png\" alt=\"\" class=\"wp-image-1102\" width=\"784\" height=\"286\" srcset=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1sJAA97yn6wyZHugPaD6wWw.png 800w, https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1sJAA97yn6wyZHugPaD6wWw-300x110.png 300w, https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1sJAA97yn6wyZHugPaD6wWw-768x280.png 768w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/figure>\n\n\n\n<p class=\"has-normal-font-size\" id=\"5ee2\">That\u2019s more like it. And as you can see from the more recent report, even Microsoft Edge is working on it. (I know, right?!?) So CSS variables are now officially A Thing You Can Actually Use! Let\u2019s see how.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why learn CSS Variables?<\/strong><\/h2>\n\n\n\n<p class=\"has-normal-font-size\">There are many reasons to use variables in CSS. One of the most compelling ones is that it reduces repetition in your stylesheet.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"347\" src=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1thf2chBMq0bJg4c1MC5Ujw.png\" alt=\"\" class=\"wp-image-1103\" srcset=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1thf2chBMq0bJg4c1MC5Ujw.png 700w, https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1thf2chBMq0bJg4c1MC5Ujw-300x149.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/figure>\n\n\n\n<p class=\"has-normal-font-size\">In the example above it\u2019s much better to create a variable for the <code>#<strong>ffeead<\/strong><\/code> color than repeating it, like we\u2019re doing here:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"449\" src=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1GrE1hZAcP_QusxbLCeQGcw.png\" alt=\"\" class=\"wp-image-1104\" srcset=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1GrE1hZAcP_QusxbLCeQGcw.png 800w, https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1GrE1hZAcP_QusxbLCeQGcw-300x168.png 300w, https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1GrE1hZAcP_QusxbLCeQGcw-768x431.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p class=\"has-normal-font-size\" id=\"7b49\">Not only will this make your code easier to read, but it gives you more flexibility as well, in case you want to change this color.<\/p>\n\n\n\n<p class=\"has-normal-font-size\" id=\"25aa\">You will have a big benefit from Css Variable<\/p>\n\n\n\n<ol class=\"has-normal-font-size wp-block-list\"><li>They don\u2019t require any transpiling to work, as they\u2019re native to the browser. So you don\u2019t need any setup to get started, as you do with SASS and LESS.<\/li><li>They live in the DOM, which opens up a ton of benefits<\/li><li>you don\u2019t want to repeat your style again<\/li><li>it will save your time when you need to apply the same rules over and over again for multiple elements<\/li><li>when we want to save a more complex property value, so that we don\u2019t have to remember it like this .<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code has-normal-font-size\" style=\"background:linear-gradient(135deg,rgb(238,238,238) 100%,rgb(169,184,195) 100%)\"><code>:root{\n \u2014 tiny-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);\n \u2014 animate-right: translateX(50px);\n}\nli{\n    box-shadow: var(--tiny-shadow);\n}\nli:hover{\n    transform: var(--animate-right);\n}<\/code><\/pre>\n\n\n\n<p class=\"has-normal-font-size\">A big advantage CSS Variables is that they have access to the DOM. This isn\u2019t the case with LESS or SASS as their variables are compiled down to regular CSS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to access variables with JavaScript<\/strong><\/h2>\n\n\n\n<p class=\"has-normal-font-size\">Another advantage of living in the DOM is that you can access the variables with JavaScript, and even update them for example.<\/p>\n\n\n\n<pre class=\"wp-block-code has-normal-font-size\" style=\"background:linear-gradient(135deg,rgb(238,238,238) 100%,rgb(169,184,195) 100%)\"><code>var root = document.querySelector(':root');<br>var rootStyles = getComputedStyle(root);<br>var mainfont = rootStyles.getPropertyValue('--main-font');console.log(mainfont); <br>--&gt; '25px'<\/code><\/pre>\n\n\n\n<p class=\"has-normal-font-size\">But if you want to update the CSS Variable simply call the <code><strong>setProperty<\/strong><\/code> method on the element in which the variables has been declared on and pass in the variable name as the first parameter and the new value as the second.<\/p>\n\n\n\n<pre class=\"wp-block-code has-normal-font-size\" style=\"background:linear-gradient(135deg,rgb(238,238,238) 100%,rgb(169,184,195) 100%)\"><code>root.style.setProperty('--main-font', '30px')<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>FAQs<\/strong><\/h2>\n\n\n\n<p class=\"has-normal-font-size\" id=\"43be\">some important question i think anyone can ask them so i have named title (FAQs)Frequently Asked Questions or (PAQs) <em>probably<\/em> ask<\/p>\n\n\n\n<p class=\"has-normal-font-size\" id=\"fcc6\"><strong>Q:<\/strong>Should I always use the <code>:root<\/code> pseudo-class as a selector to define variables?<\/p>\n\n\n\n<p class=\"has-normal-font-size\" id=\"140a\"><strong>A:<\/strong> Not necessarily i\u2019ve told that if we want to declare local variable we have\u2019not won\u2019t to do that, but usually as doing so serves a couple of purposes. First, it collects all your variables in one place for easy maintenance (especially if that\u2019s the first rule in your CSS file), which is kind of the point. Second, <code>:root<\/code>matches the whole page (essentially everything in the &lt;html&gt; element), so it makes all your variables global in scope.<\/p>\n\n\n\n<p class=\"has-normal-font-size\" id=\"2167\"><strong>Q:<\/strong> Do variable-based properties cascade?<\/p>\n\n\n\n<p class=\"has-normal-font-size\" id=\"1a30\"><strong>A:<\/strong> Yes, they are inherited like any other property. If you set a &lt;div&gt;\u2019s background color with a variable, its children will all have that background color.<\/p>\n\n\n\n<p class=\"has-normal-font-size\" id=\"6bd6\"><strong>Q:<\/strong> Are variable names case-sensitive?<\/p>\n\n\n\n<p class=\"has-normal-font-size\" id=\"87a4\"><strong>A:<\/strong> Yes, but don\u2019t get me started on case. The names <code>--h1color<\/code>,<code>--H1color<\/code>, and <code>--h1Color<\/code> are all different variables, and will gleefully cause you countless hours of debugging grief. Go ahead, use <strong>camelCase<\/strong> if you must, be attention this will make error or your browser will ignore this .<\/p>\n\n\n\n<p id=\"d622\"><strong>Q:<\/strong> Can I use dashes or underscores in variable names?<\/p>\n\n\n\n<p class=\"has-normal-font-size\" id=\"2623\"><strong>A:<\/strong> Yes, but not spaces. The names<strong> <code>--h1-color<\/code><\/strong>, <code><strong>--h1_color<\/strong><\/code>, and <code><strong>--h-1_color<\/strong><\/code> are all valid variables, while <code>--h1 color<\/code> but dashes are preferred over underscores for consistency because CSS is a dash-friendly language and uses dashes in many standard property names<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sources<\/h3>\n\n\n\n<p>very useful tutorial: <a href=\"https:\/\/web-crunch.com\/know-css-variables\/\" rel=\"noreferrer noopener\" target=\"_blank\">https:\/\/web-crunch.com\/know-css-variables\/<\/a><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-css-tricks wp-block-embed-css-tricks\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"2g5rMzAVxy\"><a href=\"https:\/\/css-tricks.com\/issue-preprocessing-css-custom-properties\/\">The Issue with Preprocessing CSS Custom Properties<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;The Issue with Preprocessing CSS Custom Properties&#8221; &#8212; CSS-Tricks\" src=\"https:\/\/css-tricks.com\/issue-preprocessing-css-custom-properties\/embed\/#?secret=39QVrOBt1g#?secret=2g5rMzAVxy\" data-secret=\"2g5rMzAVxy\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/Using_CSS_variables\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/Using_CSS_variables<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.w3.org\/TR\/css-variables\/\">https:\/\/www.w3.org\/TR\/css-variables\/<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/developers.google.com\/web\/updates\/2016\/02\/css-variables-why-should-you-care\">https:\/\/developers.google.com\/web\/updates\/2016\/02\/css-variables-why-should-you-care<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Are you looking for experts to develop your software or improve your app? Then check out our <a href=\"https:\/\/mobileaders.com\/services\/\">services <\/a>or <a href=\"https:\/\/mobileaders.com\/get_quote\/\">contact <\/a>us directly.<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CSS variables are entities defined by CSS authors that contain specific values to be reused throughout a document. They are set using custom property notation, Variables follow the same scope and inheritance rules like any other CSS definition. The easiest way to use them, is to make them globally available, by adding the declarations to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1140,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[18,20,19],"tags":[27,28,3,26,31,30,29],"class_list":["post-1099","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","category-front-end","category-web-design","tag-css","tag-design","tag-development","tag-frontend","tag-learning","tag-mobileaders","tag-webdesign"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What You Need To Know About CSS Variables ? - Mobileaders<\/title>\n<meta name=\"description\" content=\"CSS variables are entities defined by CSS authors that contain specific values to be reused throughout a document. They are set using custom property notation, Variables follow the same scope and inheritance rules like any other CSS definition. The easiest way to use them, is to make them globally available, by adding the declarations to the :root pseudo-class, so that all other selectors can inherit it.\" \/>\n<meta name=\"robots\" content=\"noindex, follow\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What You Need To Know About CSS Variables ?\" \/>\n<meta property=\"og:description\" content=\"CSS variables are entities defined by CSS authors that contain specific values to be reused throughout a document. They are set using custom property notation, Variables follow the same scope and inheritance rules like any other CSS definition. The easiest way to use them, is to make them globally available, by adding the declarations to the :root pseudo-class, so that all other selectors can inherit it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mobileaders.com\/?p=1099\" \/>\n<meta property=\"og:site_name\" content=\"Mobileaders\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/mobileaders\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-23T10:46:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-23T23:10:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1gvGL4Djch1UA52y0NgkD_g-1.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"What You Need To Know About CSS Variables ?\" \/>\n<meta name=\"twitter:description\" content=\"CSS variables are entities defined by CSS authors that contain specific values to be reused throughout a document. They are set using custom property notation, Variables follow the same scope and inheritance rules like any other CSS definition. The easiest way to use them, is to make them globally available, by adding the declarations to the :root pseudo-class, so that all other selectors can inherit it.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1gvGL4Djch1UA52y0NgkD_g-1.jpeg\" \/>\n<meta name=\"twitter:creator\" content=\"@mobileaders\" \/>\n<meta name=\"twitter:site\" content=\"@mobileaders\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mobileaders.com\/?p=1099#article\",\"isPartOf\":{\"@id\":\"https:\/\/mobileaders.com\/?p=1099\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"What You Need To Know About CSS Variables ?\",\"datePublished\":\"2022-01-23T10:46:06+00:00\",\"dateModified\":\"2022-01-23T23:10:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mobileaders.com\/?p=1099\"},\"wordCount\":841,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/mobileaders.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/mobileaders.com\/?p=1099#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/css-variables3.jpg\",\"keywords\":[\"css\",\"design\",\"development\",\"frontend\",\"learning\",\"mobileaders\",\"webdesign\"],\"articleSection\":[\"Development\",\"Front End\",\"Web Design\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mobileaders.com\/?p=1099#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mobileaders.com\/?p=1099\",\"url\":\"https:\/\/mobileaders.com\/?p=1099\",\"name\":\"What You Need To Know About CSS Variables ? - Mobileaders\",\"isPartOf\":{\"@id\":\"https:\/\/mobileaders.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/mobileaders.com\/?p=1099#primaryimage\"},\"image\":{\"@id\":\"https:\/\/mobileaders.com\/?p=1099#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/css-variables3.jpg\",\"datePublished\":\"2022-01-23T10:46:06+00:00\",\"dateModified\":\"2022-01-23T23:10:36+00:00\",\"description\":\"CSS variables are entities defined by CSS authors that contain specific values to be reused throughout a document. They are set using custom property notation, Variables follow the same scope and inheritance rules like any other CSS definition. The easiest way to use them, is to make them globally available, by adding the declarations to the :root pseudo-class, so that all other selectors can inherit it.\",\"breadcrumb\":{\"@id\":\"https:\/\/mobileaders.com\/?p=1099#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mobileaders.com\/?p=1099\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mobileaders.com\/?p=1099#primaryimage\",\"url\":\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/css-variables3.jpg\",\"contentUrl\":\"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/css-variables3.jpg\",\"width\":400,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mobileaders.com\/?p=1099#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mobileaders.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What You Need To Know About CSS Variables ?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mobileaders.com\/#website\",\"url\":\"https:\/\/mobileaders.com\/\",\"name\":\"Mobileaders\",\"description\":\"Leaders of Mobile Development!\",\"publisher\":{\"@id\":\"https:\/\/mobileaders.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mobileaders.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/mobileaders.com\/#organization\",\"name\":\"mobileaders\",\"url\":\"https:\/\/mobileaders.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mobileaders.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/mobileaders.com\/wp-content\/uploads\/2021\/12\/Logo-White-Background.png\",\"contentUrl\":\"https:\/\/mobileaders.com\/wp-content\/uploads\/2021\/12\/Logo-White-Background.png\",\"width\":1280,\"height\":720,\"caption\":\"mobileaders\"},\"image\":{\"@id\":\"https:\/\/mobileaders.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/mobileaders\",\"https:\/\/x.com\/mobileaders\",\"https:\/\/www.instagram.com\/mobileaders\",\"https:\/\/www.linkedin.com\/company\/mobileaders\"]},{\"@type\":\"Person\",\"@id\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What You Need To Know About CSS Variables ? - Mobileaders","description":"CSS variables are entities defined by CSS authors that contain specific values to be reused throughout a document. They are set using custom property notation, Variables follow the same scope and inheritance rules like any other CSS definition. The easiest way to use them, is to make them globally available, by adding the declarations to the :root pseudo-class, so that all other selectors can inherit it.","robots":{"index":"noindex","follow":"follow"},"og_locale":"en_US","og_type":"article","og_title":"What You Need To Know About CSS Variables ?","og_description":"CSS variables are entities defined by CSS authors that contain specific values to be reused throughout a document. They are set using custom property notation, Variables follow the same scope and inheritance rules like any other CSS definition. The easiest way to use them, is to make them globally available, by adding the declarations to the :root pseudo-class, so that all other selectors can inherit it.","og_url":"https:\/\/mobileaders.com\/?p=1099","og_site_name":"Mobileaders","article_publisher":"https:\/\/www.facebook.com\/mobileaders","article_published_time":"2022-01-23T10:46:06+00:00","article_modified_time":"2022-01-23T23:10:36+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1gvGL4Djch1UA52y0NgkD_g-1.jpeg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_title":"What You Need To Know About CSS Variables ?","twitter_description":"CSS variables are entities defined by CSS authors that contain specific values to be reused throughout a document. They are set using custom property notation, Variables follow the same scope and inheritance rules like any other CSS definition. The easiest way to use them, is to make them globally available, by adding the declarations to the :root pseudo-class, so that all other selectors can inherit it.","twitter_image":"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/1gvGL4Djch1UA52y0NgkD_g-1.jpeg","twitter_creator":"@mobileaders","twitter_site":"@mobileaders","twitter_misc":{"Written by":"","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mobileaders.com\/?p=1099#article","isPartOf":{"@id":"https:\/\/mobileaders.com\/?p=1099"},"author":{"name":"","@id":""},"headline":"What You Need To Know About CSS Variables ?","datePublished":"2022-01-23T10:46:06+00:00","dateModified":"2022-01-23T23:10:36+00:00","mainEntityOfPage":{"@id":"https:\/\/mobileaders.com\/?p=1099"},"wordCount":841,"commentCount":0,"publisher":{"@id":"https:\/\/mobileaders.com\/#organization"},"image":{"@id":"https:\/\/mobileaders.com\/?p=1099#primaryimage"},"thumbnailUrl":"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/css-variables3.jpg","keywords":["css","design","development","frontend","learning","mobileaders","webdesign"],"articleSection":["Development","Front End","Web Design"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mobileaders.com\/?p=1099#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mobileaders.com\/?p=1099","url":"https:\/\/mobileaders.com\/?p=1099","name":"What You Need To Know About CSS Variables ? - Mobileaders","isPartOf":{"@id":"https:\/\/mobileaders.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/mobileaders.com\/?p=1099#primaryimage"},"image":{"@id":"https:\/\/mobileaders.com\/?p=1099#primaryimage"},"thumbnailUrl":"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/css-variables3.jpg","datePublished":"2022-01-23T10:46:06+00:00","dateModified":"2022-01-23T23:10:36+00:00","description":"CSS variables are entities defined by CSS authors that contain specific values to be reused throughout a document. They are set using custom property notation, Variables follow the same scope and inheritance rules like any other CSS definition. The easiest way to use them, is to make them globally available, by adding the declarations to the :root pseudo-class, so that all other selectors can inherit it.","breadcrumb":{"@id":"https:\/\/mobileaders.com\/?p=1099#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mobileaders.com\/?p=1099"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mobileaders.com\/?p=1099#primaryimage","url":"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/css-variables3.jpg","contentUrl":"https:\/\/mobileaders.com\/wp-content\/uploads\/2022\/01\/css-variables3.jpg","width":400,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/mobileaders.com\/?p=1099#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mobileaders.com\/"},{"@type":"ListItem","position":2,"name":"What You Need To Know About CSS Variables ?"}]},{"@type":"WebSite","@id":"https:\/\/mobileaders.com\/#website","url":"https:\/\/mobileaders.com\/","name":"Mobileaders","description":"Leaders of Mobile Development!","publisher":{"@id":"https:\/\/mobileaders.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mobileaders.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/mobileaders.com\/#organization","name":"mobileaders","url":"https:\/\/mobileaders.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mobileaders.com\/#\/schema\/logo\/image\/","url":"https:\/\/mobileaders.com\/wp-content\/uploads\/2021\/12\/Logo-White-Background.png","contentUrl":"https:\/\/mobileaders.com\/wp-content\/uploads\/2021\/12\/Logo-White-Background.png","width":1280,"height":720,"caption":"mobileaders"},"image":{"@id":"https:\/\/mobileaders.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/mobileaders","https:\/\/x.com\/mobileaders","https:\/\/www.instagram.com\/mobileaders","https:\/\/www.linkedin.com\/company\/mobileaders"]},{"@type":"Person","@id":""}]}},"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/mobileaders.com\/index.php?rest_route=\/wp\/v2\/posts\/1099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mobileaders.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mobileaders.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mobileaders.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mobileaders.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1099"}],"version-history":[{"count":9,"href":"https:\/\/mobileaders.com\/index.php?rest_route=\/wp\/v2\/posts\/1099\/revisions"}],"predecessor-version":[{"id":1143,"href":"https:\/\/mobileaders.com\/index.php?rest_route=\/wp\/v2\/posts\/1099\/revisions\/1143"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mobileaders.com\/index.php?rest_route=\/wp\/v2\/media\/1140"}],"wp:attachment":[{"href":"https:\/\/mobileaders.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mobileaders.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mobileaders.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}