Get the App
SLTechnology News&Howtos  ›  Development  › 

How css excludes the first element to style other elements

Shulou Source: shulou.com Published: 2022-06-02 09:38:37 10月01日 Update

This article mainly explains "css how to exclude the first element to set the style for other elements", the content of the explanation in the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "css how to exclude the first element to set the style to other elements" bar!

In css, you can use the ": first-child" and ": not" selectors to select elements other than the first element and set the style of other elements, with the syntax of "element: not (: first-child) {css style code;}".

The operating environment of this tutorial: windows7 system, CSS3&&HTML5 version, Dell G3 computer.

How does css exclude the first element from styling other elements

In css, you can use the ": first-child" selector and ": not" selector to style elements other than the first element.

The first-child selector is used to select the specified selector of the first child element that belongs to its parent element.

The not (selector) selector matches each element that is not the specified element / selector.

Let's take a look at it through an example, which is as follows:

Document tr:not (: first-child) {background-color:red;} 111 222 333 444 555 666 777 888

Output result:

Thank you for your reading, the above is the content of "how css excludes the first element to style other elements". After the study of this article, I believe you have a deeper understanding of how css excludes the first element to style other elements, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Elements styles choices learning content examples size code that is ideas situations tutorials articles more environment computers knowledge knowledge points articles systems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information OPPO Reno macOS Shulou Technology MySQL