How to reference nested classes with css?

In CSS, classes need to be prefixed by a .ids need to be prefixed by #, and elements don’t need to be prefixed at all.

This is how you need to declare your CSS:

.box1 .box-body i {
   width: 30px;
}

Note that box1 and box-body are both classes, while i is an element.


Example:

<div class="class"></div>
<div id="id"></div>
<div></div>

I have listed three different <div> elements. This is how they would be accessed in CSS:

// first div
.class {

[some styling]

} // second div #id {

[some styling]

} // third div div {

[some styling]

}

Leave a Comment