External Libraries

Jsoup select elements with multiple classes example

Jsoup select elements with multiple classes example shows how to select elements having multiple classes.

How to select elements with multiple classes using Jsoup?

Many a times HTML elements have multiple classes applied to them using “class” attribute as given below.

It becomes little tricky to select such elements using CSS style selectors. If div had single class named “left-align”, you could have written Jsoup CSS selector like given below.

Output

If the element contains multiple classes, you can join them using separator “.” as given below.

Output

Please note that there is no space between two classes.

Here is the full example program to select div with multiple classes.

Output

Please let us know your views in the comments section below.

Tags
Join 1000+ fellow learners! Enter your email address below: