Home  >  Article  >  Web Front-end  >  What does css selector mean?

What does css selector mean?

藏色散人
藏色散人Original
2020-12-11 09:41:552568browse

css selector refers to the css selector, which is used to match DOM elements in web pages. Commonly used selectors can be divided into tag name selectors, class selectors, id selectors, derived selectors, and sub-selectors. Element selectors, grouping selectors and pseudo-element selectors.

What does css selector mean?

The operating environment of this article: windows10 system, css3, thinkpad t480 computer.

Recommended: "css Video Tutorial"

css selector refers to the css selector, which is used to match the dom elements in the web page. The css style is defined as :Selector {style}. The "selector" specifies the object of the "style" in {}, that is, which elements in the web page the "style" acts on.

To use CSS to achieve one-to-one, one-to-many or many-to-one control of elements in an HTML page, you need to use CSS selectors. Elements in HTML pages are controlled through CSS selectors.

Each css style definition consists of two parts, the form is as follows:

selector {property: value}
选择器{属性:属性值}
//即 选择器{样式}

The part before {} is the "selector". The "selector" specifies the object of the "style ()" in {}, that is, which elements in the web page the "style" acts on. It can be an HTML tag, or a tag with a specific id or class.

To put it simply: The main function of CSS is to set styles for the dom elements in the web page, and the selector is used to match the dom elements.

Commonly used selectors can be divided into: tag name selector, class selector, id selector, derived selector, child element selector, group selector, pseudo element selector.

Notes when using css selectors:

Since the interpretation of CSS is top-down, for the same attribute description of an element, the one placed below will overwrite the one located above. attribute description, so we must pay attention to the writing order when selecting elements, such as:

a:visited {color: #00FF00; text-decoration: none}
a:hover {color: #FF00FF; text-decoration: underline}

Using this writing order, no matter whether the link has been visited or not, as long as the mouse moves over the link, the link They will all turn blue and underlined. However, if the following writing order is used:

a:hover {color: #FF00FF; text-decoration: underline}
a:visited {color: #00FF00; text-decoration: none}

If the link has been visited, it will not turn blue and underlined when you move the mouse over the link, but will remain green.

The above is the detailed content of What does css selector mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn