Home  >  Article  >  Web Front-end  >  What are css selectors

What are css selectors

云罗郡主
云罗郡主Original
2018-11-24 13:41:5925502browse

In CSS, there are many types of selectors in CSS, including eight selectors such as tag selector, id selector, class selector, inheritance selector, pseudo-class selector, and global selector. .

What are css selectors

#The operating environment of this article: Windows 7 system, css3 version, Dell G3 computer.

What selectors are there in css? How many types of css selectors are there? How to use css selector? If you want to achieve one-to-one control over html, you need to use css selectors. So what are the css selectors? Let’s summarize the css selectors below.

If we use css selectors appropriately, our code will become more efficient.

What is a css selector?

We all know that css is composed of two parts, for example: body{background-color:yellow;}, where the body before {} is called a selector. Of course, the selector Also give the style in {} a name.

What are the css selectors?

In CSS, there are many types of CSS selectors, including tag selectors, id selectors, class selectors, inheritance selectors, pseudo-class selectors, global selectors, etc. There are three selectors, and the first few are the most commonly used selectors.

How to use css selector?

1. Tag selector:

An html page has many tags, and the tag selector determines the corresponding style for the tags. No matter where the element is, we will Labels can be styled using the label selector.

2. Category selector

The category selector selects based on the class name, and there is a small dot in front of it.

3.ID selector

The ID selector selects elements based on id. The id in the web page is unique, and the id can only appear once on a page.

The above is a complete introduction to the css selector. If you want to know more about CSS tutorial, please pay attention to the php Chinese website.

The above is the detailed content of What are css selectors. 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