Home >Web Front-end >CSS Tutorial >How Can I Use CSS to Clear Floats on Paragraphs Following a Specific H1?
Adjacent Sibling Selector in CSS
In CSS, the adjacent sibling selector allows you to select an element that appears immediately after another specific element. It is particularly useful for styling elements that follow a specific parent element.
Question:
You have an
tag. You want to apply the clear: both; property to all
tags that come after the
Solution:
The adjacent sibling selector is the appropriate choice in this scenario. The correct CSS rule would be:
h1.hc-reform + p { clear: both; }
This rule will select any
tag that is an immediate sibling of the
The above is the detailed content of How Can I Use CSS to Clear Floats on Paragraphs Following a Specific H1?. For more information, please follow other related articles on the PHP Chinese website!