- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Usage of var() CSS function
The var() function in CSS is used to add custom property values to your web page. Set a custom name of the property and set value for it.
Example
You can try to run the following code to implement var() function
<!DOCTYPE html> <html> <head> <style> :root { --my-bg-color: blue; --my-color: white; } #demo { background-color: var(--my-bg-color); color: var(--my-color); } </style> </head> <body> <h1>Heading One</h1> <div id = "demo"> This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. </div> <br> </body> </html>
- Related Articles
- Usage of attr() CSS function
- Usage of calc() CSS function
- Usage of rgb() CSS function
- Usage of rgba() CSS function
- Usage of hsl() CSS function
- Usage of hsla() CSS function
- Usage of linear-gradient() CSS function
- Usage of radial-gradient() CSS function
- Usage of cubic-bezier() CSS function
- Usage of repeating-linear-gradient() CSS function
- Usage of repeating-radial-gradient() CSS function
- Usage of CSS transition-timing-function property
- Usage of CSS visibility:hidden;
- Usage of CSS visibility:visible;
- Usage of CSS visibility property

Advertisements