css-Speciality of selectors_html/css_WEB-ITnose
I have suffered a loss in terms of specificity, and it’s time to sort it out~
Let’s talk about the general selector first, and the code
The most authoritative one is the "Css Authoritative Guide" 》
We divide the specificity into 4 levels. Each level represents a type of selector. The value of each level is the number of selectors it represents multiplied by this The weight of one level, and finally the special value of the selector is obtained by adding the values of all levels.
The four levels are defined as follows:
l First level: represents inline style, such as: , with a weight of 1000.
l Second level: represents the ID selector, such as: #content, with a weight of 100.
l Third level: representative classes, pseudo-classes and attribute selectors, such as .content, with a weight of 10.
l Fourth level: represents type selectors and pseudo-element selectors, such as div p, with a weight of 1.
Note: Universal selectors (*), sub-selectors (>) and adjacent sibling selectors ( ) are not in these four levels, so their weights are all 0.
The chestnuts are here
<html>#content div#main-content h2{color:red; }/*=2*100+2*1=202*/#content #main-content>h2{color:blue }/*=2*100+1=201*/body #content div[id="main-content"] h2{color:green; }/*=1*100+1*10+3*1=113*/#main-content div.paragraph h2{color:orange; }/*=1*100+1*10+2*1=112*/#main-content [class="paragraph"] h2{color:yellow; }/*=1*100+1*10+1*1=111*/div#main-content div.paragraph h2.first{color:pink;}/*=1*100+2*10+3*1=123*/</html>

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 <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

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 <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 <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

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 using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

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

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit
