I just want to know the difference between:
.class .class{
font-size:14px;
}
VS:
.class > .class{
font-size:14px;
}
Is the same thing?
Definition and Usageclass selector selects elements with a specific class attribute. To select elements with a specific class, write a period (.) character, followed by the name of the class. You can also specify that only specific HTML elements should be affected by a class.
Class is a Java class just like Object and String are classes. In short, both are essentially the same, but you can keep a reference of a String. class object using the Class class.
A div is a container tag that is used to define a division or a section in an HTML document, whereas a class is an attribute that specifies actions to be taken to one or more elements. When using a class in CSS you have to specify the HTML elements you want it to affect by using a dot(.)
The “+” sign selector is used to select the elements that are placed immediately after the specified element but not inside the particular elements.
No, they aren't the same - the first example is a descendant selector, the second is a direct child selector.
.class .class
will target all elements with the class .class
which derive from any element which has the class .class
, e.g
<div class="class">
<div class="other">
<div class="class"> This is targeted. </div>
</div>
</div>
jsFiddle example
.class > .class
will only target direct children of elements with the class .class
, e.g
<div class="class">
<div class="other">
<div class="class">This isn't targeted.</div>
</div>
<div class="class">
<div class="class">This is targeted, as it is a direct child.</div>
</div>
</div>
jsFiddle example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With