Get the App
SLTechnology News&Howtos  ›  Development  › 

How does css select a label

Shulou Source: shulou.com Published: 2022-06-02 08:17:40 10月02日 Update

This article mainly explains "how to select tags for css". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how css selects tags".

Css to select the tag method: 1, the use of id selector, syntax for "# id name {css code;}"; 2, the use of class selector, syntax for ". Class name {css code;}"; 3, the use of tag selector, syntax for "* {css code;}".

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

How does css select the tag?

There are four ways to select tags in css, which are also four selectors.

1. Id selector

According to the specified id name, find the corresponding unique tag in the current interface, and then set the property

# id name {attribute: value;} id selector # p1 {color: red;} # p2 {color: green;} # p3 {color: blue;} most people are handsome, floating on the surface and handsome in appearance

And EGON is not only handsome on the outside, but also handsome on the inside.

EGON is me. I'm EGON.

2. Class, class selector

According to the specified class name, find the corresponding label in the current interface, and then set the properties

. Class name {attribute: value;}

Example

Id selector .p1 {color: red;} .p2 {color: green;} .p3 {color: blue;} most people are handsome, floating on the surface, handsome in appearance

And EGON is not only handsome on the outside, but also handsome on the inside.

EGON is me. I'm EGON.

# practice the color of the first and third lines is red. The font size of the first and second lines is 50px. The second and third lines have an underlined id selector. P1 {color: red;} .p2 {font-size: 50px;} .p3 {text-decoration: underline;} first line content

The second line

The third line

3. Tag selector

Find all tags with that name in the current interface according to the specified tag name, and then set the properties

Tag name {attribute: value;}

Examples are as follows:

Tag selector p {color: red;}

EGON's beautiful appearance actually hides a restless heart.

This heart is called Qiqiao exquisite Heart. Men will cry when they eat it, while women will get pregnant after eating it.

4. Wildcard selector

Select all tags

* {attribute: value;} wildcard selector * {color: red;} I am the title, I am the paragraph

I am hyperlinked to this, I believe you have a deeper understanding of "css how to select the tag", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Tags selections attributes content name appearance code that is syntax one line method interface class name wildcard three lines heart example surface several people learning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Tech Info Redmi Linux MySQL