What are the basic selectors of css?

青灯夜游
Release: 2023-01-03 09:25:34
Original
21644 people have browsed it

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;
}
Copy after login

(2) class selector

There is an attribute class in each HTML tag

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

.haha {
    background-color:blue;
}
Copy after login

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

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template