.pbta:only-child p{ font-size: 36px; } 
  <div class="row pbta"> <div class="col-md-3"> <a class="recent" href=#> <img src="img/man_1.jpg" height="200" width="200" alt="JD"> <div class="info d-none"> <p>sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem.</p> </div> </a> <H5>Jonh Doeeh</H5> <p>Lead Designer</p> </div> </div> 

  • Maybe because it is not only-child? There is not enough information in your question - Alexey Ten
  • htmlbook.ru/css/only-child - Pseudo - class : only-child is applied to a child element only if it is unique to the parent. - soledar10
  • Example - jsfiddle.net/soledar10/2kzqwcqo - soledar10
  • In the snippet does not work, because there after him an empty script lies. And why you do not work - no one knows. - Qwertiy

1 answer 1

you added the wrong pseudo-class, it works if it is only one pseudo-class for the parent: only-child should be assigned to the element itself that you want to change, and it is not necessary that paragraph P is the only, but generally the only element of the parent, even if you just add a DIV neighbor this paragraph you will not work pseudo class ...

 .pbta p:only-child { font-size: 36px; color: orange; } 
 <div class="row pbta"> <div class="col-md-3"> <a class="recent" href=#> <img src="img/man_1.jpg" height="200" width="200" alt="JD"> <div class="info d-none"> <p>sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem.</p> </div> </a> <H5>Jonh Doeeh</H5> <p>Lead Designer</p> </div> </div> 

  • I need this rule to be distributed only within the parent container .pbta - sunnyrio
  • show which paragraph you want to change? - Air
  • and more, you have an error, in html / you have a div inside the "a" tag, and a lowercase, blocky, blocking div cannot be thrust - Air
  • <p> sit sit d none>>>> sit <>> sit sit fu fu fu,,,,,,,,,,, sed sed sed sed sed magn magn magn magn magn os os <<</ p> </ div> - окт
  • and if the reference class in the class indicates that display: inline-block, then it is possible to place blocks in it? - sunnyrio