Well, this is usually considered a good style to separate code and content from each other as much as possible. If you use this method, you have wonderfully pure HTML:
<span id="myElement">moo</span>
and a separate central repository of code that you can store in one place, and you can even add an external Javascript file.
Editing an HTML layout becomes really fun and it looks great.
I do not always follow this rule in the letter itself, and I am not so jealous of it as of others. But I allow myself the maximum of calling the onclick='do_stuff()' function when executing inline strings. Everything more complex turns into a soup code very quickly.
source share