


What are CSS selectors? CSS selector priority determination
Jul 28, 2018 am 10:58 AMThe selector specifies the tag that CSS is to act on, and the name of that tag is the selector. Meaning: Which container to choose (the label itself is the container that encapsulates the data).
##
@CHARSET "UTF-8"; /*css中選擇器有很多種,第一種就是最基本的元素選擇器(又稱類型選擇器)。 *文檔的元素就是最基本的選擇器。 *如果設(shè)置 HTML 的樣式,選擇器通常將是某個(gè) HTML 元素, * 比如 p、h1、em、a,甚至可以是 html 本身: */ h2{ color:blue; } /*第二種選擇器: 類樣式選擇器 */ /*對(duì)所有 "aa"類樣式進(jìn)行設(shè)置 .aa{ background-color: #00FF00; } */ /*僅僅是對(duì)p中的"aa"類樣式進(jìn)行設(shè)置*/ p.aa{ background-color: #00FF00; } .bb{ background-color: #004444; } /*第三種選擇器 id選擇器 *ID 選擇器允許以一種獨(dú)立于文檔元素的方式來(lái)指定樣式。 *在某些方面,ID 選擇器類似于類選擇器,不過(guò)也有一些重要差別。 */ /*id選擇器*/ #d1{ background-color: #0000FF; } /*其他選擇器*/ /*1.關(guān)聯(lián)選擇器*/ p span{/*選擇p標(biāo)簽容器中的span*/ font-size:20pt; } /*2.組合選擇器*/ p span,.c,#d1{ color:red; } /*3.偽元素選擇器*/ /*CSS 偽元素用于向某些選擇器設(shè)置特殊效果。*/ span:HOVER { background-color:#FFFF00; font-size: 20pt; cursor: pointer; } a{ text-decoration: none; } /*L-V-H-A*/ a:link{ color: red; font-size: 12pt; } a:visited{ color:blue; font-size: 16pt; } a:hover{ background-color: #00FF00; font-size:20pt; } a:active{ color:#FFFF00; } input:focus{ background-color: #00FFFF; } /*星號(hào)選擇器,選擇所有*/ *{ text-decoration: underline; } /*屬性選擇器,所有具有type屬性的元素*/ [type]{ margin: 10px; } /*具有name屬性且屬性值為'math'*/ [name="math"]{ background-color: #0ff; } a[href="http://www.w3school.com.cn/"][title="W3School"] { color: red; } /* 關(guān)聯(lián)選擇器---后代 */ h1 em{ color: red; } /*子元素選擇器---兒子*/ p > em{ color: blue; } /*相鄰元素選擇器---后續(xù)兄弟*/ li + li { font-weight:bold; }Related articles:
css Class Selector And id selector
Related video:Class selector-2016 new course system html css video
The above is the detailed content of What are CSS selectors? CSS selector priority determination. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Setting the size of HTML text boxes is a very common operation in front-end development. This article explains how to set the size of a text box and provides specific code examples. In HTML, you can use CSS to set the size of a text box. The specific code is as follows: input[type="text"

H5 page production refers to the creation of cross-platform compatible web pages using technologies such as HTML5, CSS3 and JavaScript. Its core lies in the browser's parsing code, rendering structure, style and interactive functions. Common technologies include animation effects, responsive design, and data interaction. To avoid errors, developers should be debugged; performance optimization and best practices include image format optimization, request reduction and code specifications, etc. to improve loading speed and code quality.

How to adjust WordPress themes to avoid misaligned display requires specific code examples. As a powerful CMS system, WordPress is loved by many website developers and webmasters. However, when using WordPress to create a website, you often encounter the problem of theme misalignment, which affects the user experience and page beauty. Therefore, it is very important to properly adjust your WordPress theme to avoid misaligned display. This article will introduce how to adjust the theme through specific code examples.

H5 page production process: design: plan page layout, style and content; HTML structure construction: use HTML tags to build a page framework; CSS style writing: use CSS to control the appearance and layout of the page; JavaScript interaction implementation: write code to achieve page animation and interaction; Performance optimization: compress pictures, code and reduce HTTP requests to improve page loading speed.

In Angular app, how to change the color of the icon when the mouse is hovered over it? Many developers will encounter needs when building applications using Angular...

How to solve the display problem caused by user agent style sheets? When using the Edge browser, a div element in the project cannot be displayed. After checking, I posted...

Dynamic web element crawling problem: dealing with XPath and Class name changes, many crawler developers will encounter a difficult problem when crawling dynamic web pages: the goal...

CSS selector priority is determined in the following order: Specificity (ID > Class > Type > Wildcard) Source order (Inline > Internal style sheet > External style sheet > User agent style sheet) Declaration order (latest declarations take precedence) Importance (!important forces the priority to increase)
