Reputation: 29720
I usually just figure this out as I go and eventually it works but I am trying to work out what the difference really is so I can become a bit more adept with CSS, that in mind what is the difference between...
H2.class
and
H2 .class
and can I do....
.class.H2 ?
Upvotes: 0
Views: 91
Reputation: 15860
H2.class
means the h2
tag with class="class"
H2 .class
Means an element inside h2
tag with class="class"
such as:
<h2>THis is <span class"class">it</span></h2>
And so on..
.class.H2 ?
means the element with class of class with a class of h2
.
Upvotes: 0
Reputation: 13221
The first H2.class
will apply a style to this:
<h2 class="class"></h2>
The second H2 .class
will apply a style to this:
<h2><ANY class="class"></ANY></h2>
And lastly the third .class.H2
will apply a style to this:
<ANY class="class H2"></ANY>
Have a read up on MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/Syntax?redirectlocale=en-US&redirectslug=CSS%2FSyntax
Upvotes: 1
Reputation:
H2.class
<h2 class="class">stuff</div>
H2 .class
<h2><span class="class"></span></h2>
Upvotes: 2
Reputation: 15699
1) H2.class means <h2 class="class">..
<h2>
having class 'class'
2) H2 .class means <h2><div class="class">..
<h2>
having descendent '.class'
3) .class.H2 means <h2 class="class">..
same as first
Upvotes: 0