Jsoup cannot go through the CSS DOM, although you can access it by selecting a style / link on the tags.
Take a look at CSS Parser , it looks very promising.
InputSource source = new InputSource( new StringReader( "h1 { background: #ffcc44; } div { color: red; }")); CSSOMParser parser = new CSSOMParser(new SACParserCSS3()); CSSStyleSheet sheet = parser.parseStyleSheet(source, null, null); CSSRuleList rules = sheet.getCssRules(); for (int i = 0; i < rules.getLength(); i++) { final CSSRule rule = rules.item(i); System.out.println(rule.getCssText()); }
Output
h1 { background: rgb(255, 204, 68) } div { color: red }
source share