9

I'm adding alt attributes to all my images to improve SEO/screen reader performance.

Per best practice, images that are purely aesthetic should have an empty alt attribute alt=""so screen readers skip over them. I'm in WordPress and noticed it does add alt to these descriptionless aesthetic images, but not alt="".

Does alt get read the same as alt="" by screen readers and search engine crawlers, or should I go in and programatically force an alt=""?

1
  • I think that's a stretch - sure SEO is involved but it's also a specific question about HTML and how it gets read. Anyone with a similar question for various reasons can look at this question and learn about Empty Attribute Syntax. Specific code is being referenced here - I think this belongs. Jun 27, 2017 at 15:38

1 Answer 1

14

Yes, it's the same: https://html.spec.whatwg.org/multipage/syntax.html#attributes-2

Empty attribute syntax

Just the attribute name. The value is implicitly the empty string.

To me, that says that an attribute with no value is the same as having a value of empty string.

This answer says the same.

2
  • 1
    Ahh, googling 'Empty attribute syntax' was very helpful - I've never used that phrase before. Here's another good post w/ a link to a validator to test which attributes can be used this way: stackoverflow.com/a/32949851/6647188 Thanks KarlReid! Jun 26, 2017 at 16:54
  • 1
    I didn't know it either before today, I guess I just got lucky with my googling and found good information.
    – Karl Reid
    Jun 26, 2017 at 16:55

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.