BUG: Fix user-facing AssertionError with to_html (#25608)
- [x] closes #25608
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

I did not use an oxford comma in the error description, which is how it was written in the issue's expected result.