+ 3
Use period or pound?
when styling element in css use period or pound? what is difference of . or #?
3 odpowiedzi
+ 3
# is for styling elements targeted by their assigned id. . is for styling by their assigned class.
Elements can have multiple classes but only one id.
+ 3
# is for id and .(dot) is for class
for example
<html>
<head>
<title> id and class </title>
<style>
.container{
width:110px;
height:100px;
background-color:green;
}
#box{
width:100px;
height:40px;
background-color:red;
}
</style>
</head>
<body>
<div class="container">
<div id="box"></div>
<div id="box"></div>
</div>
</body>
</html>
the output is:
there are two red boxes within a green container.
in this sample div structure is very important. because
right after coding div structure, you have to apply css attributes to your div structure.