Three common style selectors in html css

Three common style selectors in html css

1: Tag selector

The tag selector is used for all tags. Here we take p as an example, that is, all the tags with p will have this style.


Copy code
The code is as follows:

<html>
<head>
<styletype="text/css">
p{font:"宋体"; color:#FF0000}
</style>
</head>
<body>
<pid="p1">I am now showing the tag selector</p>
<pid="p2">I also use the tag selector</p>
<h1>I am not modified by any selector</h1>
</body>
</html>

2: id selector . Note that the id selector is unique, because only id="yy" has this style, and the ID of an element in a page must be unique, so. . . You know that the id selector starts with # and is used as follows: id=""


Copy code
The code is as follows:

<html>
<head>
<styletype="text/css">
#yy{font:"宋体"; color:#FF0000}
</style>
</head>
<body>
<pid="yy">I am now showing the id selector</p>
<pid="p">I am not modified by the id selector</p>
<h1>I am not modified by any selector</h1>
</body>
</html>

3: Class selector . Class selectors start with . Just set the element's class="" to display this style. The usage is: class=""


Copy code
The code is as follows:

<html>
<head>
<styletype="text/css">
.yy{font:"宋体"; color:#FF0000}
</style>
</head>
<body>
<pclass="yy">I am now showing the class selector</p>
<pclass="yy">I am not modified by the class selector</p>
<h1>I am not modified by any selector</h1>
</body>
</html>

<<:  Centos8.3, docker deployment springboot project actual case analysis

>>:  CSS perfectly solves the problem of front-end image deformation

Recommend

A mobile adaptive web page effect solves the problem of small display page

For work needs, I need to make a mobile phone adap...

Mysql command line mode access operation mysql database operation

Usage Environment In cmd mode, enter mysql --vers...

Three implementation methods of Mysql copy table and grant analysis

How to quickly copy a table First, create a table...

Understanding Nginx Current Limitation in One Article (Simple Implementation)

Nginx is now one of the most popular load balance...

NodeJS realizes image text segmentation

This article shares the specific code of NodeJS t...

el-table in vue realizes automatic ceiling effect (supports fixed)

Table of contents Preface Implementation ideas Ef...

MySQL Series Database Design Three Paradigm Tutorial Examples

Table of contents 1. Knowledge description of the...

Introduction to the usage of props in Vue

Preface: In Vue, props can be used to connect ori...

Learning to build React scaffolding

1. Complexity of front-end engineering If we are ...

Docker installs mysql and solves the Chinese garbled problem

Table of contents 1. Pull the mysql image 2. Chec...

Mysql aggregate function nested use operation

Purpose: Nested use of MySQL aggregate functions ...

How to implement load balancing in MySQL

Preface MySQL is a high-speed, high-performance, ...

VMware Workstation Pro 16 License Key with Usage Tutorial

VMware Workstation is a powerful desktop virtual ...