CSS four basic selectors

What is the css selector?

To use css to achieve one-to-one, one-to-many or many-to-one control of elements in HTML pages, CSS selectors are needed.

The elements in the HTML page are controlled by CSS selectors.

CSS selector: It is to specify the label to be used by CSS, and the name of that label is the selector. It means: which container to choose.

CSS selectors are divided into two categories: basic multiple-choice questions and extended selectors.

Basic selector:
1. Tag selector: for a class of tags
2. ID selector: for a specific tag use
3. Class selector: for Use all tags you want
4. Universal selector (wildcard): applicable to all tags (not recommended)

1. Tag selector:A complete HTML page is composed of many different tags, and the tag selector determines which tags use the corresponding CSS style, (in a large environment You may come from a different position, but no matter what, you always wear the same suit. This suit is pre-defined for you by the label selector, and it is this suit no matter where you go)

As shown below:

style type=”text/css”>
p{
font-size:40px;
}

Tag selector< /p>

2.id selector:Select the element according to the element ID, which is unique. It is marked with “#” in front.


Document


id selector

3. Category selection Device: The class selector selects based on the class name. Very similar to id, any tag can carry id attribute and class attribute. But the id attribute can only be referenced once by a particular tag.

As shown below:

Paragraph

Paragraph

Paragraph

4. Wildcard* : Matching all tags is not recommended.

Leave a Comment

Your email address will not be published.