It comes from the early web when scraping web pages was a thing. Html is not always clean, missing end tags, cross nested tags, invalid tags, misused tags or you need xhtml&#x2F;xml compatible html so you can do xpath&#x2F;xslt on it.