62 |
63 |
64 |
65 |

66 | 70 |

71 | 77 |
78 | 79 |

80 | 💥 Please make sure to paste in valid CSS. 81 |

82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |

🌟 About this tool

98 |

99 | With the above tool you get a quick overview of selectors and their specificities across 100 | a CSS file in bird’s-eye view. 101 |

102 |

103 | It’s a visual way to identify potentially problematic patterns and especially useful for 104 | analyzing very big and complex stylesheets. 105 |

106 |

107 | Be sure to read the 108 | blog post introducing the Specificity Visualizer. 111 |

112 |

Main features and differences to other tools

113 |
    114 |
  • 115 | 🤩 It’s a pretty fun and nice visual experience and potentially changes the way how 116 | you look into and think about your stylesheets. 117 |
  • 118 |
  • 119 | 🔍 Hover over single data points to see the exact selector or zoom into areas of 120 | interest, e.g. you can look at only the selectors of the first half of the file or you 121 | can zoom into all selectors with the specificity of 0,2,1 across the 122 | entire file. 123 |
  • 124 |
  • 125 | 📊 To better distinguish different specificity categories the data points are using 126 | proper colors and forms. You can also click on a legend item to toggle its visibility, 127 | e.g. if you want to only see ID selectors. 128 |
  • 129 |
  • 130 | 📸️ Taking screenshots of the chart is great to track progress, e.g. you could save a 131 | snapshot of your stylesheet before and after a major refactoring to visualize the 132 | difference. Also, you could use it for presentations to effectively communicate to 133 | other developers and/or stakeholders. 134 |
  • 135 |
  • 136 | 📏 Specificities aren’t simply “added up” but rather treated as proper categories. 137 | After all, no amount of class selectors can overrule an ID selector. 138 | Also, selectors inside of @media, @supports and 139 | @document blocks are counted, selectors inside of 140 | @keyframes blocks aren’t. 141 |
  • 142 |
143 |

How to read the chart

144 |
    145 |
  • 146 | The x-axis shows the physical location of selectors as they are written in the 147 | CSS. On the left side is the first one, on the right side the last one. 148 |
  • 149 |
  • 150 | The y-axis shows the specificity of selectors, beginning with the least specific one 151 | at the bottom and ending with the most specific one at the top. 152 |
  • 153 |
154 |

What is considered a “good” or “bad” graph?

155 |
    156 |
  • 157 | First off, think of the chart more as a rough conceptual model and not as an exact 158 | tool. 159 |
  • 160 |
  • 161 | A spiky graph with an overall high specificity and high amount of noise can be 162 | considered as potentially “bad”. 163 |
  • 164 |
  • 165 | An upward-trending graph with overall low specificity and low amount of noise can be 166 | considered potentially “good”. 167 |
  • 168 |
169 |

170 | Please be sure to read the 171 | additional articles on this topic. 172 |

173 |
174 |
175 | 176 |
177 |
178 |

🤓 Additional articles on this topic

179 |

180 | Check out these resources if you want to dig deeper into how specificity graphs can help 181 | you getting an overview of big stylesheets and what the reasoning behind it is: 182 |

183 | 216 |

217 | Do you know of any other articles that are missing here? 218 | Feel free to suggest one! 219 |

220 |
221 |
222 |
223 |
224 |

🔨 Other tools you might find useful

225 |

226 | There are a ton of other tools out there that can help you analyzing your 227 | CSS and the specificity of your selectors: 228 |

229 | 278 |

279 | Do you know of any other tools that are missing here? 280 | Feel free to suggest one! 281 |

282 |
283 |
284 |
285 |
286 |

💕 Contributing

287 |

288 | Did you spot an error? Do you miss a feature? Please be sure to check out 289 | the list of existing issues 292 | before creating 293 | one of your own. Any feedback and help is appreciated. 296 |

297 |
298 |
299 |
300 |
301 |

🤝 Credits and further links

302 | 335 |
336 |
337 |
338 |
339 |

📖 License

340 |

341 | This repository is published under the 342 | MIT license. 345 |

346 |
347 |
348 |