Except where otherwise specified, the alt attribute must be specified and its value must not be empty; the value must be an appropriate functional replacement for the image. The specific requirements for the alt attribute content depend on the image's function in the page, as described in the following sections.
This is a guidence with a long history, and it still works now.
In the W3C Recommendation of HTML5: