Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the selector of Css?

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is about what the selector of Css is. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Three main selectors of CSS.

1. Generic tags: the p in CSS code is used to select HTML elements

.

two。 Class (classes): .intro in the CSS code is used to select the HTML element with the attribute class= "intro".

The # logo in the 3.ids:CSS code is used to select the HTML element with the attribute id= "logo".

All of these selectors can be attached with pseudo classes (pseudo-classes). A pseudo class is used to:

Define the special state of an element, which is often related to the dynamic interactive behavior of the user or the dynamic structural characteristics of the document, so it cannot be written into the HTML document in advance.

It's a keyword that starts with a colon (colon).

Pseudo classes cannot exist alone. It must be attached to a selector. The pseudo class will just define the special state of that selector. The syntax looks like this:

. selector:pseudo-class {}

There is no space between the selector and the pseudo class, between the selector and the pseudo-class, to indicate that they are concatenated.

: hover

A common pseudo class is hover, which is used to style a target element in a hovering state (that is, the state triggered when the user hovers over the element). We can use this pseudo class for links. Because hovering is the most basic link interaction.

A {color: blue;}

A:hover {color: red;}

The first line defines that all links are blue. The second line defines that when hovering, the link color is red. The second line selects the same HTML element, but a specific behavior occurs. (in this case, a user hover action occurred.)

: visited

The target object of this pseudo class is the visited link. By default, the link is blue and turns purple when accessed (clicked or touched) by you.

Examples are as follows:

CSS code

A {color: dodgerblue;}

A:visited {color: rebeccapurple;}

Thank you for reading! This is the end of the article on "what is the selector of Css". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report