I read the following, but I don;t fully understand the meaning of these selectors. Could you please provide an example showing the difference between them? Thx.
            Asked
            
        
        
            Active
            
        
            Viewed 264 times
        
    -3
            
            
        - 
                    This is one of the most basic concepts in CSS. If you look up any guide or lesson on CSS selectors you'll find this explained. – Bram Vanroy Sep 05 '17 at 11:25
 - 
                    That's CSS 1 not CSS 3. Also HTML 4, not 5. – Quentin Sep 05 '17 at 11:28
 - 
                    @Quentin: I imagine he assumes 3 is part of the technology name, and not a version number. As most people new to web development do. – BoltClock Sep 05 '17 at 11:30
 - 
                    1Why the downvotes!!! My answer is correct. – DjaouadNM Sep 05 '17 at 11:46
 - 
                    @BramVanroy, the topic on selectors is found in many references. However, not every reference list all possible example. I have checked several references and found no example for this case. – NoChance Sep 05 '17 at 11:51
 - 
                    @Quentin, is there a new implementation for this case in CSS3? – NoChance Sep 05 '17 at 11:52
 - 
                    @NoChance — No. The implementation of descendant combinators has remained unchanged (although their name has changed). – Quentin Sep 05 '17 at 12:11
 - 
                    @NoChance — The official spec has an example for that case: https://www.w3.org/TR/css3-selectors/#descendant-combinators – Quentin Sep 05 '17 at 12:12
 - 
                    1A class selector and a descendant selector are found in any basic CSS reference... As Quentin rightfully pointed out, you can also find an overview of all selectors in the spec. – Bram Vanroy Sep 05 '17 at 12:25
 - 
                    @BramVanroy, thanks for pointing the duplicate, (although it is not exact duplicate), – NoChance Sep 05 '17 at 12:32
 - 
                    @Quentin, thanks for pointing out the example. – NoChance Sep 05 '17 at 12:33
 
2 Answers
-1
            
            
        P{
  border: 1px solid black;
  width: 100px;
}
P.para {
  color: red;
  }
P .para {
  color: blue;
}
<p class="para"> <!--P tag with class para-->
  sth
</p>
    
<p> <!--P with child having class para-->
  <span class="para"> 
    sth
  </span>
  xyz <!-- xyz is element of p -->
</p> <!--Or any descendant not just children-->
Both "sth" will change with any css rule but "xyz" is not.
        Ahmet Karabulut
        
- 153
 - 1
 - 12
 
- 
                    1
 - 
                    "P with child having class para" — It selects the descendant, not the paragraph itself. – Quentin Sep 05 '17 at 11:31
 - 
                    
 - 
                    
 - 
                    
 - 
                    
 - 
                    
 
-1
            p.para { /* <p class="para">, similar to p[class="para"] */
   color:red;
}
p .para { /* any descendants, that have class="para", of <p> */
   color:blue;
}
<p class="para">
  P.Para {}
</p>
<p>
  <span class="para">
     P .Para {}
  </span>
</p>
        DjaouadNM
        
- 22,013
 - 4
 - 33
 - 55
 
- 
                    1
 - 
                    "any `
` with child that has class="para" */" — No. It selects the descendant, not the paragraph itself.
– Quentin Sep 05 '17 at 11:30 - 
                    
 - 
                    "any descendants of `
` that have class="para"" — That's ambiguous. It's "any descendants, that have class="para", of `
`"
– Quentin Sep 05 '17 at 11:33 - 
                    
 
