{"id":1334,"date":"2009-12-02T19:12:01","date_gmt":"2009-12-02T17:12:01","guid":{"rendered":"http:\/\/www.blog.atbliss.ru\/?p=1334"},"modified":"2017-07-17T11:03:46","modified_gmt":"2017-07-17T09:03:46","slug":"calculating-selectors-specificity","status":"publish","type":"post","link":"https:\/\/atbliss.ru\/calculating-selectors-specificity\/","title":{"rendered":"\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u043e\u0432"},"content":{"rendered":"
\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n
The specificity is based only on the form of the selector. In particular, a selector of the form «[id=p33]» is counted as an attribute selector (a=0, b=0, c=1, d=0), even if the id attribute is defined as an «ID» in the source document’s DTD.<\/p>\n
\u0421\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0447\u0438\u0441\u0435\u043b a-b-c-d (\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435\u043c) \u0434\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0443.<\/p>\n
\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n
* {} \/* a=0 b=0 c=0 d=0 -> specificity = 0,0,0,0 *\/\r\n li {} \/* a=0 b=0 c=0 d=1 -> specificity = 0,0,0,1 *\/\r\n li:first-line {} \/* a=0 b=0 c=0 d=2 -> specificity = 0,0,0,2 *\/\r\n ul li {} \/* a=0 b=0 c=0 d=2 -> specificity = 0,0,0,2 *\/\r\n ul ol+li {} \/* a=0 b=0 c=0 d=3 -> specificity = 0,0,0,3 *\/\r\n h1 + *[rel=up]{} \/* a=0 b=0 c=1 d=1 -> specificity = 0,0,1,1 *\/\r\n ul ol li.red {} \/* a=0 b=0 c=1 d=3 -> specificity = 0,0,1,3 *\/\r\n li.red.level {} \/* a=0 b=0 c=2 d=1 -> specificity = 0,0,2,1 *\/\r\n #x34y {} \/* a=0 b=1 c=0 d=0 -> specificity = 0,1,0,0 *\/\r\n style=\"\" \/* a=1 b=0 c=0 d=0 -> specificity = 1,0,0,0 *\/\r\n<\/code><\/pre>\n<head>\r\n<style type=\"text\/css\">#warning { color: red }<\/style>\r\n<\/head>\r\n<body>\r\n<p id=warning style=\"color: green\">\r\n<\/body><\/code><\/pre>\n\u0412 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0446\u0432\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <p> \u0431\u0443\u0434\u0435\u0442 \u0437\u0435\u043b\u0435\u043d\u044b\u043c. \u0414\u0435\u043a\u043b\u0430\u0440\u0430\u0446\u0438\u044f «style» \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432 \u043a\u0430\u0441\u043a\u0430\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441\u0442\u0438\u043b\u0435\u0439, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u043e\u0441\u0442\u044c.<\/p>\n
\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u0437\u0434\u0435\u0441\u044c: <\/p>\n
Calculating a selector’s specificity \u2014\u00a0\/\/www.w3.org\/TR\/CSS2\/cascade.html#specificity<\/address>\n","protected":false},"excerpt":{"rendered":"\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: count 1 if the declaration is from is a ‘style’ attribute rather than a rule with a selector, 0 otherwise (= a) (In HTML, values of an element’s «style» attribute are style sheet rules. These rules have no selectors, so a=1, b=0, c=0, and d=0.) \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 id […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"yoast_head":"\n
\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u043e\u0432<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n