


Introduction to the invalid solution when defining multiple class attributes in HTML
Define multiple values for the class attribute. It is often found that the defined style is invalid. After testing, when defining multiple class values, you must pay attention to putting your favorite style at the end, otherwise it will be invalid.
In the process of writing HTML, we often define multiple values for the class attribute, but we also often find that the values we define are invalid! ! !
In the past, when I encountered this situation, I directly rewritten it, or directly used the ID to set the css attribute. Today, when I think about it, something seems wrong. . . I have to find the truth! ! !
The code is as follows:
<p id="p" class="middle_p padding_10"> <span id="s" class="normal_span"></span> </p>
The colors I set in the two classes are different. The color set in middle_p is red, and the color set in padding_10 is green.
The result is displayed in green, which gives me the first impression: the direction is reversed!
So I switched the two positions, and it was still green! !
this. . . .
Is that so? ? ?
Open the css file and see that padding_10 is in front of middle_p. Then I swap their positions,
Refresh the browser, red! ! !
So, when defining multiple class values, be sure to put your favorite style at the end!
But, if you add a p in front of padding_10 (assuming the parent element is p), it becomes p.padding_10, and then you will find that no matter where it is, our p p is always green,
It can be seen from this example that the priority of the css style is determined when the css file is loaded, rather than determined by the position of the class attribute in the subsequent html.
For more related articles on invalid solutions when multiple class attributes are defined in HTML, please pay attention to the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...
