I stump upon some discussion recently about empty alt=”” for decorative images according to W3C and this brings me to the analysis of a source code of my generated page with hugo
I am using this command to generate it on Netlify
```
hugo --gc --minify
```
this resulting generating IMG tag with just word alt
As understand Hugo uses an underlying library (usually tdewolff/minify) that aggressively removes quotes from attributes wherever the HTML spec allows it to save bytes.
In HTML5, alt (without quotes or an equals sign) is technically a boolean attribute ?
I read suggestion to add this:
```
[minify.tdewolff.html]
keepDefaultAttrVals = true
keepQuotes = true
```
But aren’t this shall be a default approach?
aren’t Hugo minifier going too far on minifying?
Alt is definitely not a boolean, so while semantically you are correct, there is no issue because syntactically the empty attribute syntax is allowed in HTML5 for any empty attribute, not just for boolean attributes.
So, technically, the minifier is correctly applying the HTML5 spec to the letter. The <img src="..." alt> syntax will cause no issues for HTML parsers, or screen readers.
From a W3C/HTML5 specification standpoint, the minifier is behaving perfectly. Syntactically, <img alt> is a valid way to represent an empty attribute.
I am analysing this from the difference of Technical Validity and Search Engine Heuristics.
Many SEO audits and crawlers interpret alt (with no value and no equals sign) as a “Missing Value.”
the annoying Bing.
HTML5 says:<img alt> is fine. Bingbot says: “I see the word ‘alt’, but I don’t see ="", so I’m flagging it as missing.”
Thanks for your input. It helps me concentrate in a slightly different direction.
The thing you are stumbling over is that what we old people call “html attributes” nowadays is properties and attributes. alt will always be an attribute and having only the alt in a tag will result in “alt being empty”. If it would be a property then it would be boolean. (something along these lines, people who spent their lives learning that will probably have “correct” answer)
The second thing that is NOT a rule is having alt="" in your code to appease the validators. alt is the same as alt="" - as in “this image does not have alternative content”. It started back when the w3c validator came out and suddenly everyone added empty alt text to their images because everyone thought if w3c validator complains about not alt text then Google certainly deranks your site.
Now you as developer/author have to make sure that your images have proper accessibility. And having no alt title for a flourish on your website is perfectly ok. If it’s an image of a bird in a bird-watchers website it MUST have an alt description.
If you want to make your sleep better, then add an aria-hidden to every image that you have no alt tag for.
And please take warnings/errors from validators as advise only. They can’t check for accessibility properly these days, which is why they are more verbose about “potential” issues.
I wonder how many people end up on a website crawled by bing bot. It’s probably less resource hogging to ignore it if that is the only one complaining.