Refactor private functions out of HtmlElement to simplify the class api