a class in css code example
Example 1: css class
.myclass {
border:1px solid black;
background-color: #d2d2d2;
height:20px;
width:60px;
}
Example 2: how to create a css class
<style>
.myclass {
background-color: transparent;
height:50px;
width:50px;
}
</style>
<body>
<div class="myclass"></div>
<body>
Example 3: . and # in css
<!DOCTYPE html>
<html>
<head>
<style>
.classname {
background-color: green;
color: white;
}
#idname {
background-color: pink;
color: white;
}
</style>
</head>
<body>
<div class="classname">I am green colour<div>
<div id="idname">I am pink colour</div>
</body>
</html>