Is inline event handlers considered a bad practice?
For example: <button onclick=someFunction()>Click me!</button>
If so, what are the disadvantages of using inline event handlers?
Is inline event handlers considered a bad practice?
For example: <button onclick=someFunction()>Click me!</button>
If so, what are the disadvantages of using inline event handlers?
Aside from semantics and other opinions expressed in the accepted answer, all inline scripts are considered a vulnerability and high security risk. Any website expecting to run on modern browsers are expected to set the 'Content-Security-Policy' (CSP) property, either via meta attribute or headers.
Doing so is incompatible with all inline script and styles unless explicitly allowing these as an exclusion. While CSP goals are mainly about preventing persistent cross-site script (xss) threats, for which inline scripts and styles are a vector of xss, it is not default behaviour currently in browsers but may change in future.
Building on @Mitya answer.
In most of the modern JS libraries React, Vue,..etc. inline event handlers are considered idiomatic, but most of the limitation mentioned by @Mitya are gone. As case study we will have look over Vuejs and compare it with point listed above:
onclick are not plain string but js expressions look hereIn my own opinion, inline event handler enhance readability majorly, but opinions may vary.