Get the App
SLTechnology News&Howtos  ›  Development  › 

How to express the CSS neighbor sibling selector

Shulou Source: shulou.com Published: 2022-06-01 04:15:33 10月03日 Update

This article "CSS neighboring brother selector how to express" most people do not understand, so the editor summed up the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "CSS neighboring brother selector how to express" article.

The neighboring sibling selector uses the plus sign (+), which is the neighboring sibling combinator (Adjacent sibling combinator).

Note: like the child combinator, there can be a blank character next to the neighboring sibling combinator.

Take a look at the following document tree fragment:

List item 1 List item 2 List item 3 List item 1 List item 2 List item 3

In the above snippet, the div element contains two lists: an unordered list and an ordered list, each containing three list items. The two lists are neighboring brothers, and the list items themselves are neighboring brothers. However, the list items in the first list and the list items in the second list are not adjacent brothers, because the two sets of list items do not belong to the same parent element (cousins at most).

Keep in mind that you can only select the second element of two neighboring brothers with a combination. Look at the selector below:

Li + li {font-weight:bold;}

The above selector only changes the second and third list items in the list to bold. The first list item is not affected.

The above is about "CSS neighboring brother selector how to express" the content of this article, I believe we all have a certain understanding, I hope the editor to share the content to help you, if you want to know more related knowledge, please follow the industry information channel.

Tags: Brothers selection content two elements three articles clips knowledge articles please see noodles order value plus sign cousins most of them that is documents Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker OPPO Reno NVidia Huawei