Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to solve the problem that multiple class attributes defined in HTML are invalid

Shulou Source: shulou.com Published: 2022-05-31 13:13:47 11月11日 Update

This "HTML definition of multiple class attributes invalid how to solve" article most people do not understand, so the editor summarized the following content, detailed, clear steps, with a certain reference value, I hope you can read this article can be reaped, let's take a look at this "HTML definition of multiple class attributes invalid how to solve" article it.

Question:

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

The result is green, which gives me the first feeling is: in the opposite direction!

So I swapped the two positions, still green!

It's, uh...

Is it?

When I opened the css file, I saw that padding_10 was in front of middle_div, and then I switched their positions.

Refresh the browser, red!

So, when defining multiple class values, be sure to put your favorite style behind!

But if you add a div in front of the padding_10 (assuming the parent element is div) and become div.padding_10, then you will find that our p div is always green no matter where it is.

As you can see from this example, the priority of the css style is determined when the css file is loaded, not by the location of the class attribute in the html later.

The above is about the content of this article on "how to solve the invalid definition of multiple class attributes in HTML". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Content multiple attributes green location two that is files articles times styles knowledge articles red differences values priorities examples elements most of them Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux NVidia OPPO Reno Shulou Technology Huawei