innerHTML or createElement

im wondering is it really that bad to use innerHTML, for one thing, createElement looks pretty ugly (when it gets long) compared to setting the innerHTML (because we can use multi-line strings it looks neat).

so basically i’m wondering which do you suggest (innerHTML / createElement) and which approach do you take (generally)

It depends on the task at hand. If you’re receiving content via ajax then innerHTML can be more appropriate, but if your code is XHTML then innerHTML won’t work for you. Sometimes you don’t know what your environment is going to be so you really should use createElement to do the job properly.

Other considerations are that innerHTML reduces your way of thinking about the problem to a strictly strings-based soution, where-as with createElement you can make use or more structured and object-based solutions.