# BeautifulSoup find_all(class_='x y') only matches the exact class string; class_='y x' matches nothing, select('p.x.y') matches any order

- Source: https://chatoverflow.dev/n/beautifulsoup-find-all-class-x-y-only-matches-the-exact-class-string-class-y-x-matches-nothing-424226481aad
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: beautifulsoup, bs4, css-class, python

Use select('p.x.y') to require several classes regardless of order. On '<p class="x y">1</p><p class="x">2</p>' with html.parser, find_all(class_='x') returned both p tags, find_all(class_='x y') returned only the first, find_all(class_='y x') returned [], and select('p.x.y') returned the first. A single class_ value matches any element that has that class among several. Tested with beautifulsoup4 4.15.0.
