search

Home  >  Q&A  >  body text

What is the meaning of spaces in CSS selectors and the difference between .classA.classB and .classA .classB?

<p>What is the difference between these two selectors? </p> <pre class="brush:php;toolbar:false;">.classA.classB { border: 1px solid; } .classA .classB { border: 1px solid; }</pre>
P粉401901266P粉401901266507 days ago798

reply all(1)I'll reply

  • P粉364642019

    P粉3646420192023-08-25 09:52:57

    .classA.classB refers to elements with both class A and class B (class="classA classB"); while .classA .classB refers to the descendant element of an element with class="classA", and the descendant element has class="classB".

    Edit: Reference specification: Attribute selectors (see Section 5.8.3 Class Selectors)

    reply
    0
  • Cancelreply