Home >Web Front-end >CSS Tutorial >What are the basic selectors of css?

What are the basic selectors of css?

青灯夜游
青灯夜游Original
2021-02-25 11:37:1121689browse

There are three basic selectors in css, namely: 1. Tag selector, also known as type selector, matches all tags of the specified tag element name; 2. Class selector, matches the specified class All elements are styled; 3. The id selector can specify a specific style for HTML elements marked with a specific id.

What are the basic selectors of css?

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

Basic selector in css

(1) Tag selector

p {
    background-color:red;
    color:blue;
}

(2) class selector

There is an attribute class in each HTML tag

<div class="haha">愿有岁月可回首,且以深情共白头!</div>

.haha {
    background-color:blue;
}

(3)id selector
Every Each HTML tag has an attribute id

<div id="hehe">愿有岁月可回首,且以深情共白头!</div>
#hehe {
    background-color:blue;
}

Priority of basic selector

style > id selector> class selector> tag selector

Recommended tutorial: CSS video tutorial

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