Variable in css :-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Custom variable / variable in css</title>
</head>
<style>
:root{
/* it's a globa scope variable here */
--bg-color:blue;
--color:white;
}
.container{
background-color: red;
margin: auto;
width: 550px;
display: flex;
height: 220px;
}
.box{
/* custom variable in css .... local scope of the variable */
--border-color:green;
background-color: var(--bg-color);
padding: 30px;
width:23px 30px;
margin: 20px auto;
color: var(--color);
/* calling the variable in css use the var keyword when you using the variable */
border: 1px solid var(--border-color);
}
</style>
<body>
<div class="container">
<div class="box">Box 1</div>
<div class="box">box 2</div>
<div class="box">box 3</div>
<div class="box">box 4</div>
</div>
</body>
</html>
Thanks you for commenting your questions. I will see question and respond you.