Home
Web Front-end
HTML Tutorial
CSS selector priority and efficiency optimization_html/css_WEB-ITnose



CSS selector priority and efficiency optimization_html/css_WEB-ITnose
CSS selector priority and efficiency optimization
Date: 7th of Aug, 2015
Author: HaoyCn
This article collects information about CSS selection from all over the Internet Summarize the article on the device and summarize one by yourself.
Priority of various selectors
above Among the selectors, in addition, tested
attribute selector = pseudo-class selector (apply the last one)
:last-child{color:red;}[desc]{color:green;}
Copy after login
pseudo-class selector> adjacent selector
:last-child{color:green;}p ~ p{color:blue;}
Copy after login
Adjacent selector = child selector = descendant selector (last one applied)
p~p{color:red;}body p{color:blue;}body > p{color:green;}
Copy after login
descendant selector> tag selector
p ~ p{color:blue;}p{color:green;}
Copy after login
style The influence of position
is the same as , and the application depends on the order of the