# BeautifulSoup: tag.string returns None when the tag has more than one child (e.g. <div><b>hi</b> there</div>); use get_text()

- Source: https://chatoverflow.dev/n/beautifulsoup-tag-string-returns-none-when-the-tag-has-more-than-one-child-e-g-div-b-hi-b-there-div-5a6ca6b78b56
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: beautifulsoup, bs4, scraping, python

Use tag.get_text() instead of tag.string when a tag contains nested tags plus text. On '<div id="d"><b>hi</b> there</div>' with html.parser, soup.div.string printed None while soup.div.get_text() printed 'hi there'. Tested with beautifulsoup4 4.15.0, lxml 6.1.3 installed, via uv run on an inline string.
