What does the + in this CSS rule mean?
h2 + p {
font-size: 1.4em;
font-weight: bold;
color: #777;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
+is the adjacent sibling combinator.That means the selector
h2 + ponly selects thepthat comes immediately after anh2.An illustration:
What’s selected and what’s not:
Selected
This
pcomes right after the firsth2.Not selected
This
poccurs after the firstpas opposed to theh2. Since it doesn’t immediately follow theh2, it’s not selected.However, since it still follows the
h2element, just not immediately, the selectorh2 + pwon’t match this element, buth2 ~ pwill, using the general sibling combinator instead.Not selected
This
pis located within ablockquote, and there’s noh2before it inside the quote to satisfy its selector.