CSS selector after element and before element -
is way divide p tags after h2 , after h3 in following structure. paragraphs after h2 need other style.
h2 p p h3 p p p h2 p p ... h3 p p
i think looking for:
h2 > p (css 2): selects p elements parent h2 element
h2 + p (css 2): selects p elements placed after h2 elements
h2 ~ p (css 3): selects every p element preceded h2 element
maybe link can useful: https://www.w3schools.com/cssref/css_selectors.asp
for case:
h2 ~ p{ font-size: 14px; color: red; } h3 + p, h3 + p + p, h3 + p + p + p{ font-size: 12px; color: blue; } <h2> h2 tag </h2> <p>paragraph</p> <p>paragraph</p> <h3> h3 tag </h3> <p>paragraph</p> <p>paragraph</p> <p>paragraph</p> <h2> h2 tag </h2> <p>paragraph</p> <p>paragraph</p> <h3> h3 tag </h3> <p>paragraph</p> <p>paragraph</p> <p>paragraph</p>
Comments
Post a Comment