Invalid solution when defining multiple class attributes in HTML

Invalid solution when defining multiple class attributes in HTML
In the process of writing HTML, we often define multiple values ​​for class attributes, but we also often find that the values ​​we define are invalid! ! !

In the past, when I encountered this situation, I would just rewrite it, or directly use the id to set the CSS attribute. Today, I think something is wrong. . . I have to discover the truth! ! !

Copy code
The code is as follows:

<div id="p" class="middle_div padding_10">
<span id="s" class="normal_span"></span>
</div>

I set different colors in the two classes, red in middle_div and green in padding_10.

The result showed green, and my first feeling was: the direction was wrong!

So I swapped the two positions, and it was still green! !

this. . . .

Could it be? ? ?

I opened the CSS file and saw that padding_10 was in front of middle_div. Then I swapped their positions.

Refresh the browser, red! ! !

So, when defining multiple class values, be sure to put your favorite style at the end!
However, if you add a div in front of padding_10 (assuming the parent element is a div), it becomes div.padding_10, then you will find that no matter where it is, our p div is always green.

From this example, we can see that the priority of the CSS style is determined when the CSS file is loaded, rather than being determined by the position of the class attribute in the HTML later.

<<:  MySQL Series 10 MySQL Transaction Isolation to Implement Concurrency Control

>>:  Vue Element-ui implements tree control node adding icon detailed explanation

Recommend

Summary of basic usage of $ symbol in Linux

Linux version: CentOS 7 [root@azfdbdfsdf230lqdg1b...

How to use the Linux md5sum command

01. Command Overview md5sum - Calculate and verif...

Detailed explanation of Vue's methods and properties

Vue methods and properties 1. Methods Usage 1 met...

How to import CSS styles into HTML external style sheets

The link-in style is to put all the styles in one...

Web page text design should be like smart girls wearing clothes

<br />"There are no ugly women in the w...

Introduction to the functions and usage of value and name attributes in Html

1. The value used in the button refers to the text...

Detailed discussion of MySQL stored procedures and stored functions

1 Stored Procedure 1.1 What is a stored procedure...

Count the list tags in HTML

1. <dl> defines a list, <dt> defines ...

Web page creation basic declaration document type description (DTD

Using CSS layout to create web pages that comply w...

Complete steps to quickly configure HugePages under Linux system

Preface Regarding HugePages and Oracle database o...

Encapsulate the navigation bar component with Vue

Preface: Fully encapsulating a functional module ...

Solve the cross-domain problem of get and post requests of vue $http

Vue $http get and post request cross-domain probl...

Let's talk about the characteristics and isolation levels of MySQL transactions

The Internet is already saturated with articles o...