Is there a way, or a tool, which can be used to get a list of the names of all the classes / ids contained within a css file?
I need to build an xml mapping of all css classes / ids, and doing it manually is very tedious for css files that contain thousands of styles.
You Can Use Both ID and CSS Class Selectors There are no rules in HTML that prevent you from assigning an element both an ID and a class. This <div> tag will be subject to the styles for the class backgroundOrange .
ID and Class Selector As we covered above, you can target elements with a combination of ID and class .
To select elements with a specific class, write a period (.) character, followed by the name of the class. You can also specify that only specific HTML elements should be affected by a class. To do this, start with the element name, then write the period (.)
In console execute the following code:
Array.prototype.forEach.call(document.styleSheets[0].cssRules,function(a){console.log(a.selectorText)})
In the console will be the listing of all css tags used in your stylesheet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With