how do I copy background html code of a div

I’m making a free custom website creator tool with drag and drop.
One can make the desired page by dragging elements to a div section which is then reviewed.
I want the user to copy the code inside that div section so he may be able to use it.
I’m totally new to java so I don’t know how to do so.
Please help me that how can I copy The code inside a div. So, I may be able to help people to generate their own custom templates without paying a single dollar.

note: this is a static website so nothing is being done on the server.