Move build_element_from_tag out of the HTML parser.

This function is not particular to the parser, so should live in the DOM.