Explain the differences between a class selector and an id selector in styling with an example for EACH of them.
Example 1: css class
.myclass {
border:1px solid black;
background-color: #d2d2d2;
height:20px;
width:60px;
}
Example 2: . 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>