Skip to content

Commit b69cc66

Browse files
authored
chapter 1 - 1.8 uploaded
chapter 1 - 1.8 uploaded
1 parent 4545542 commit b69cc66

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Topics included/covered
6363
[Using CSS Variables](#15-using-css-variables)
6464
- 1.6. [CSS Variables vs Preprocessor Variables](#16-css-variables-vs-preprocessor-variables) | [Difference Between CSS Variables and Preprocessor Variables](#16-difference-between-css-variables-and-preprocessor-variables)
6565
- 1.7. [CSS Variables with JavaScript](#17-css-variables-with-javascript)
66+
- 1.8. [CSS Variables var() function](#18-css-variables-var-function)
6667

6768
2. [CSS Variables Practical Demo Examples](#2-css-variables-practical-demo-examples)
6869
- 2.1. [Managing Colors-Theme](#21-managing-colors-theme )
@@ -907,6 +908,20 @@ root.style.setProperty('--base-bg-color', '#f66969') // red- #f66969; green - #6
907908
</figure>
908909
</p>
909910

911+
1.8. CSS Variables var() function
912+
---------------------
913+
914+
- Any CSS variables defined in the stylesheet can be `accessed` by using `var()` function
915+
- The CSS `var()` function can be used to insert the value of a custom property or a CSS variable
916+
- The var() function cannot be used in any property names, selectors or anything else besides property values setting or providing fallback value support
917+
918+
> **Syntax**: ``` var(<custom-name>, <value>) ``` <br/>
919+
> **Syntax**: ``` var( <custom-property-name> , <declaration-value>? ) ```
920+
921+
- ```var(--main-color, #ff7f50) ```
922+
- **`<custom-name>`**: **Required** Parameter. It's the custom property's name (must start with two dashes)
923+
- **`<value>`**: **Optional**. The fallback value. Used only if the custom property is invalid or not defined or not found in stylesheet context (fallback support)
924+
910925
2 CSS Variables Practical Demo Examples
911926
=====================
912927

0 commit comments

Comments
 (0)