Hi all,
The approximative sibling or adjacent sibling combines two selectors. + works as combinator.
For example:
p {color : green;}
p + p { color:red;}
HTML:-
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor </p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor </p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor </p>
<span>THIS IS A SPAN </span>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor </p>
<div>THIS IS A DIV</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor </p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor </p>
</div>
Out put :-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
THIS IS A SPAN
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
THIS IS A DIV
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
Now we can see some p tags output are green and some are red. Which paragraph tag that is directly (no any element in between) after another paragraph tag that are red and other are green.
0 Comment(s)