September 21, 2012
Style will not apply without using a ','
Question by Norman
I just noticed, using the css code below ignores the .input.cmp bit :
.create input.cmp, input.email, input.pswd, input.pswda{}
while using the code below (with a , before) works fine.
.create ,input.cmp, input.email, input.pswd, input.pswda{}
How is this happening? Is this the right way to do it? Or am I doing something wrong here.
I previously used to use an ID instead of class and things worked fine without the first ‘,’
Answer by Starx
This seems to be like a misunderstanding and logical error .
.create input.cmp,
selectsinput.cmp
inside.create
.create ,input.cmp,
are two different selectors.create
andinput.cmp
Here is an simple example:
.create input.cmp
selects the input element ONLY in the following HTML
<div class="create">
<input type="text" class="img" />
</div>
Where as, .create ,input.cmp
selects both div
and input
elements.