Consider the following HTML:
<div>
<p>
<strong>Title</strong>
</p>
<p>
some resular text....
</p>
</div>
I want to add padding to paragraph only if it has 'strong' inside it.
Is it possible using CSS only (no JS)?
Consider the following HTML:
<div>
<p>
<strong>Title</strong>
</p>
<p>
some resular text....
</p>
</div>
I want to add padding to paragraph only if it has 'strong' inside it.
Is it possible using CSS only (no JS)?
Yes, you can. Refer this post for learning the rules.
Demo: https://jsfiddle.net/n05jaua4/3/
HTML:
<div>
<p>
<strong>Title inside paragraph</strong>
</p>
<p>
some resular text....
</p>
</div>
<strong>Title</strong>
CSS:
p strong{
padding-top: 50px;
padding-right: 30px;
padding-bottom: 50px;
padding-left: 80px;
}