kwk.stack
kwk.stack

Reputation: 553

apply display none property of css on a paragraph

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

Answers (2)

Ben
Ben

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

j08691
j08691

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}

jsFiddle example

Upvotes: 3

Related Questions