I came across the following tag in CSS3. Being 'CSSmenu' div class name. I have problem in understanding the remaining syntax like :
why referred with dot(.)
I came across the following tag in CSS3. Being 'CSSmenu' div class name. I have problem in understanding the remaining syntax like :
why referred with dot(.)
.a
refers to all the elements which has the class a
div.a
refers to all div which has the class a
div .a
refers to all children of a div which has the class a
That's the same for your example :
.cssmenu.align-center
refers to all the elements which has the classes cssmenu
AND align-center
.cssmenu .has-sub
refers to all the elements which has the class has-sub
and are children of an element which has the class .cssmenu
.cssmenu.aligncenter
is used to select a div with multiple classes. That is, I want to select the cssmenu
which has another class align-center
.
.cssmenu .has-sub
is used to select a div which has .has-sub
nested within. Also known as Descendent selector.
.cssmenu.aligncenter {
text-align: center;
}
.cssmenu .hassub {
font-style: italic;
font-size: 2em;
}
<div class="cssmenu">Not centered and not bold</div>
<div class="cssmenu aligncenter">Text centered</div>
<div class="cssmenu">
<div class="hassub">It contains subsections, so I am Italic</div>
</div>