News for hackers. Stuff that matters.
Re:Front-End Checklist by Raphmedia on Wednesday October 18, 2017 @02:44PM (#15501780)
> Alternative text: High All <img> have an alternative text which describe the image visually.

Please don't do that. Don't put an alt on ALL images. Screen readers will read all of them. Skin and flavour images don't deserve to be read outloud. Nobody wants to hear "bottom left corner of logo" or "rounded corner".

Re:Front-End Checklist by robin_reala on Wednesday October 18, 2017 @02:52PM (#15501852)
Typically you’d use background images for something like that. Regardless, if you do have an image that doesn’t add anything to the information on the page give it an empty alt attribute to indicate to the screen reader that it shouldn’t try to read out the file name or something.
Re:Front-End Checklist by Teichopsia on Wednesday October 18, 2017 @02:54PM (#15501886)

  <img src=".." alt="">
Do you mean like that? Empty quotes and it would not be read?
Re:Front-End Checklist by robin_reala on Wednesday October 18, 2017 @03:12PM (#15502036)
Exactly. Every img element should have an alt attribute; those with visual content should have explanatory text in it.
Re:Front-End Checklist by drusepth on Wednesday October 18, 2017 @08:31PM (#15504512)
What is the value of having an alt attribute if its value is blank? Just to tell someone poking at the source code that, "yeah, I know I'm supposed to have this, and it's intentionally left blank"?
Re:Front-End Checklist by fold_left on Thursday October 19, 2017 @02:20AM (#15505825)
No, the reason given was

> give it an empty alt attribute to indicate to the screen reader that it shouldn’t try to read out the file name or something

Re:Front-End Checklist by Teichopsia on Wednesday October 18, 2017 @03:40PM (#15502238)
:D I knew that. I'm not that noobish.

Let's see. If we use an image that doesn't add anything to the content, one would normally use background-attachment to add an image to say, the hero section.

(It seems you edited your comment?)

Good to know that the screen reader would try to read the file name if there isn't any alt text in it, I didn't know that. So, in the cases we do need to place an img in the document, then we simple place an empty alt text as in my above comment to tell the screen reader not to read the file name since it is only used for decorative purposes...?

Edit: I confused your comment with another one.

Re:Front-End Checklist by twhb on Wednesday October 18, 2017 @07:53PM (#15504327)
FYI, in HTML5 <img src=".." alt=""> is equactly equivalent to <img src=".." alt>. Value-less attributes become attributes with empty string values at the tokenizer level.
Re:Front-End Checklist by epmatsw on Wednesday October 18, 2017 @08:37PM (#15504541)
Hmm. Why not aria-hidden=true?
Re:Front-End Checklist by leepowers on Wednesday October 18, 2017 @04:58PM (#15503011)
Seconding this. It very much depends on the purpose of the image. If an image or any other tag is extraneous in a screen reader context use the `aria-hidden`[1] attribute to exclude it.

A good example is an image used as an icon next to a text label. Imagine a link/button that contains the words "Save" and a floppy disk icon. There's no need to have an alt of "Save" on the icon as the text "Save" is already present. So it would look something like this:

    <a href="#"><img src="save-icon.png" aria-hidden="true">Save</a>
Though in this case you'd probably be using an icon font like FontAwesome.

[1] https://stackoverflow.com/questions/31107040/whats-the-diffe...

Re:Front-End Checklist by extra88 on Thursday October 19, 2017 @12:06PM (#15509095)
The first rule of ARIA is don't use it if you don't have to. An img element with an empty alt attribute will tell the screen reader not to read it and is more widely supported than the aria-hidden attribute.

'aria-hidden' is for HTML elements that don't have their own way of hiding themselves from assistive technologies and for cases where you'll use JavaScript to change the element's hidden state. I can't think of a situation where you'd want to conditionally show and hide only an image only from screen readers but if you had that situation, toggling aria-hidden would be better than adding and removing the alt attribute's value.

Re:Front-End Checklist by FilterSweep on Wednesday October 18, 2017 @03:28PM (#15502158)
> Nobody wants to hear "bottom left corner of logo" or "rounded corner".

I would assume front-end guys care more about passing a Web Accessibility[0] audit than inconveniencing some users, thus good taste and wise discretion is spared for avoidance of litigation.

[0] https://www.w3.org/TR/WCAG20-TECHS/H37.html

Re:Front-End Checklist by mrlase on Wednesday October 18, 2017 @06:29PM (#15503826)
While that link is part of WCAG 2.0, there are other items within the standard to follow such as: https://www.w3.org/TR/WCAG20-TECHS/H67.html. Decorative images are not supposed to be read by the screen reader.

https://www.w3.org/WAI/tutorials/images/decorative/

Re:Front-End Checklist by rimliu on Wednesday October 18, 2017 @03:00PM (#15501934)
This recommendation would be fine 20 years ago. You should not have any decorative images in your markup, they belong to CSS.
Re:Front-End Checklist by Raphmedia on Thursday October 19, 2017 @10:27AM (#15508181)
Agreed but it does happen. Sometimes, the line between content and decorative it pretty thin.

Should you add an alt to a stock photo?

Should you disturb a user with a reading of "stock photo of a business man smiling" next to a sales paragraph? What about "sunset over a mountain" on a page for a SaaS website?

Re:Front-End Checklist by extra88 on Thursday October 19, 2017 @12:24PM (#15509276)
Some people disagree but I think most say the stock photos should have alternative text. The photo is there for a reason, to convey something, and the text should indicate that (though usually not explicitly). Usually you don't use "photo" in alt text, the assistive technology will announce "image" with the text, and usually you don't want to call attention to the fact that an image is a stock photo. "Businessman smiling" or "smiling man in suit" would probably be good. You might add some adjectives that help convey why the image was used, "peaceful sunset over mountain."

The goal is not so much to make the best experience for the assistive technology user but to provide as close to the same experience as possible, bullshit marketing crap and all.

Re:Front-End Checklist by corymayfield on Wednesday October 18, 2017 @05:09PM (#15503133)
Some people like myself work in places where there are still some clients that ask for IE6 compatibility and have to comply with WCAG 2.0 accessibility standards.
Re:Front-End Checklist by gspetr on Wednesday October 18, 2017 @11:09PM (#15505204)
What makes it worth it for you to keep working there?
Re:Front-End Checklist by seanwilson on Wednesday October 18, 2017 @04:37PM (#15502770)
Why? It shouldn't make any difference if you add alt="" to the img tag.
Re:Front-End Checklist by jinglebells on Wednesday October 18, 2017 @04:45PM (#15502847)
Because you shouldn't be using <img> tags for layout. Nobody does.
Re:Front-End Checklist by seanwilson on Wednesday October 18, 2017 @04:49PM (#15502914)
What's the reasoning behind such a rule?
Re:Front-End Checklist by ozaark on Wednesday October 18, 2017 @04:56PM (#15502988)
Style is separate from content. ie. Screen readers/robots don't care about gradients etc.
Re:Front-End Checklist by seanwilson on Wednesday October 18, 2017 @05:23PM (#15503268)
I'm not seeing any practical benefits mentioned so this sounds like dogmatism to me. Using an img tag can sometimes just be more practical (e.g. if you're using a CMS or for use with a JS plugin). Google Image search definitely cares about images as well. I agree separating style from content has benefits but doing this at all costs isn't worth the time in my opinion and a few img tags seem harmless to me. It reminds me of how people are against JSX on principle that code and HTML should never be mixed without attempting to consider any of the benefits.
Re:Front-End Checklist by ozaark on Thursday October 19, 2017 @12:13PM (#15509171)
Practical benefit: users and search engines parse the content of the page for information about the subject matter, including Google Images. I agree having an img with an empty alt tag is OK, but it's not helping search optimization and neither is alt=round corner gradient (unless of course that is your subject matter :-)

Imagine reading a printed text page about dogs and peppered throughout the text was mentions of 'bezel flare 2' or similar. If it doesn't make sense for that to be on the page as text alone then it shouldn't be on the page at all.

Re:Front-End Checklist by seanwilson on Thursday October 19, 2017 @02:18PM (#15510252)
It just doesn't sound significant to me. Crawlers and screen readers happily ignore div and span tags that add nothing to the content, they ignore mobile scaling meta tags in the head etc.
Re:Front-End Checklist by ozaark on Thursday October 19, 2017 @02:53PM (#15510580)
> they ignore mobile scaling meta tags in the head

Actually the meta viewport "Helps Google’s algorithms accurately assign indexing properties to the page rather than needing to signal the existence of corresponding desktop/mobile pages." [1]

Every bit of code on a page is interpreted a certain way for a reason. HTML5 now has more semantic tags like header and nav that add an additional layer of certainty over context. I'll concede that most developers seem to not care about the reasons why so long as they can push code to production faster.

[1] https://developers.google.com/search/mobile-sites/mobile-seo...

Re:Front-End Checklist by rimliu on Friday October 20, 2017 @07:13AM (#15514857)
So sad http://www.csszengarden.com/ is already forgotten :(
Re:Front-End Checklist by daviddiasfront on Friday October 20, 2017 @12:07PM (#15516877)
It is not! :) That website change the vision of CSS for lot of people.