Reputation: 553
i am working on css and i want to display none the p tag width refrence of div class ""abc but unable to do so i also cannot put and class in p tag as its auto generating so the use of refrence is must but in correct way. any help please.
here is the html:
<div class="abc">any text</div>
<p>any text here</p>
here is the css i tried so far:
.abc p{ display:none}
but i know its not correct i also search it on google but no luck.
Upvotes: 0
Views: 1675
Reputation: 10146
For that CSS to work, you need to contain your paragraph within your div:
<div class="abc"><p>any text here</p></div>
Or given your markup, the sibling selector:
.abc + p { display:none }
Upvotes: 1
Reputation: 207861
Try the adjacent sibling selector +
. It will select only the element that is immediately preceded by the former element:
.abc + p{ display:none}
Upvotes: 3