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=""?

unor
  • 92,415
  • 26
  • 211
  • 360
Kyle Vassella
  • 2,296
  • 10
  • 32
  • 62
  • 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. – Kyle Vassella Jun 27 '17 at 15:38

1 Answers1

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.

maryisdead
  • 1,792
  • 2
  • 19
  • 30
Karl Reid
  • 2,147
  • 1
  • 10
  • 16
  • 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: https://stackoverflow.com/a/32949851/6647188 Thanks KarlReid! – Kyle Vassella Jun 26 '17 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 '17 at 16:55