How to add elements to existing HTML using DomDocument?

Lets be a little more specific - you can do this during Execution Time. Once the page has been rendered to the browser, you’re in Javascript’s territory unless the page is reloaded. During execution time, absolutely it’s doable with DOM/XML methods. Also string methods. Quite possibly array methods as well, depending on how the original HTML is constructed.