Accessibility: alt or alt="" for decorative images - html

In terms of WCAG 2.0 accessibility, is an empty alt-tag equally valid if it's written alt or alt="" in the html?
Like this:
<img src="some-image.jpg" alt="">
<img src="some-image.jpg" alt>
Are they both valid for stating decorative images?
Inspecting an image with alt="" in a browser's DevTools will display alt, so is it valid to just write alt in the html?

Both should be treated equally.
According to the HTML Standard:
Empty attribute syntax
Just the attribute name. The value is implicitly the empty string.

They are the same: https://stackoverflow.com/a/44764507/18717610
A screen reader will not read the image with an empty alt attribute.

Related

Images must have alternate text: Element has no title attribute

What is meant by Images must have alternate text: Element has no title attribute
I had created img tag but developer tools gives me a warning but i can't understand what that means.
Affected resources
<img src="./img/twitter.png">
This has to do with screen readers. Screen readers have no way of translating an image into words that gets read to the user, even if the image only consists of text. As a result, it's necessary for images to have short, descriptive alt text so screen reader users clearly understand the image's contents and purpose.
There are 3 ways to give an image alternate text:
Using an alt attribute i.e. <img alt="drawing of a cat" src="...">
Using an aria-label i.e. <img aria-label="drawing of a cat" src="...">
Using an aria-labelledby attribute i.e. <img arialabelledby="someID" src="..."
The alt attribute is needed when the picture is not available or the user turned all pictures off in his/her browser. It's necessary to include this attribute to your img elements.
<img src=".." alt="Alternative text" width="200" height="100" aria-label="For screen readers" />
Use alternate txt for img tag like this : <img src="./img/twitter.png" alt="tweetImg"> .
As it is important, if there is slow connection the alternate txt will be visible or due to some error your image don't show up .
The HTMLImageElement property alt provides fallback (alternate) text to display when the image specified by the element is not loaded.
This may be the case because of an error, because the user has disabled the loading of images, or because the image hasn't finished loading yet.
See this to read more about alt

How to use ALT tag correctly?

I have used the ALT tags for all my images with this format:
<a alt="IMAGE ALT TEXT" href="http://2.bp.blogspot.com/-MEHRDQvoG-c/Ux0mL1mlJII/AAAAAAAAGg8/S9h3KjhJ6YQ/s1600/jquery-lightbox-with-dark-background.png" imageanchor="1"><img src="http://2.bp.blogspot.com/-MEHRDQvoG-c/Ux0mL1mlJII/AAAAAAAAGg8/S9h3KjhJ6YQ/s320/jquery-lightbox-with-dark-background.png" style="height:100%; width:100%;" /></a>
But I was surprised when the image checker tools sensed their alt tags as "missing". I supposed I had to insert the "alt" tag after the "img src" tag like that:
<img src="http://2.bp.blogspot.com/-MEHRDQvoG-c/Ux0mL1mlJII/AAAAAAAAGg8/S9h3KjhJ6YQ/s320/jquery-lightbox-with-dark-background.png" alt="IMAGE ALT TEXT" style="height:100%; width:100%;" />
Tell me please will this style correct?
alt is a property of IMG tag and not of A tag. It stands for alternative text to be shown or read by screen readers. So the second example you provided is the right one.
The alt attribute must be on the element and not on the hyperlink element.
You may be confusing the "alt" tag and the "title" tag.
The "alt" tag is used with images:
<img src="someImage.jpg" alt="image">
The title tag can be used with BOTH images and links
<img src="someImage.jpg alt="image" title="Some Image">
<a href="someLink.com" title="This is some link">
There wouldn't be any need for an "alt" tag on a traditional link, because even if the link was bad, there would still be text wrapped in the anchor indicating what it is:
Link to some link
With the image, the "alt" property value only displays when the image, for whatever reason, isn't available.
the alt should be only used in <applet>, <area>, <img>, <input>
alt - <applet>, <area>, <img>, <input> - Alternative text in case an
image can't be displayed.
Source
here is a snippet of img:
<img src="http://lorempixel.com/100/100" alt="image">

Is <img src="[srcpath]" alt=""> the same as <img src="[srcpath]" alt> when it comes to accessibility?

<img src="[srcpath]" alt="">
<img src="[srcpath]" alt>
That is to say:
Are those both considered null values for image alt text? Or must you ensure the alt="" is present?
You should use the alt="" attribute. Each example of the null alt attribute in the specs for providing alternative text for an image explicitly uses it. Here's another resource on the empty alt="" attribute
However.. if I were to look at the DOM inspector in Chrome and look at an img that had alt="" in the source code, I would see <img src="[srcpath]" alt>.
The Failure Criterion F65 in the WCAG 2.0 standards note that the presence of the alt attribute is sought. It does not clarify whether or not the alt attribute must be explicitly declared as empty (alt="") for HTML5 standards, and as long as you're using the HTML according to the spec, having <img src="[srcpath]" alt> would technically be considered accessible.
So in summary - yes, they technically are the same when it comes to accessibility, but I'm not one to derive from given instruction. By using alt="", you are being aware of the purpose of the alt attribute, and keeping consistency in your alt techniques with respect to the HTML specifications.
Both have the empty string as value, so they are equivalent.
HTML5 defines that attributes can be specified in four different ways, among them the "Empty attribute syntax":
Just the attribute name. The value is implicitly the empty string.

What does the alt tag mean in HTML

I am just learning HTML. I have a confusion on using image and alt in learning HTML. When I use alt it doesn't go to the alt image.
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
When I try to use my own example, or image, it doesn't work.
The alt attribute specifies an alternate text for the image, if it cannot be displayed.
The alt attribute is required in HTML4 and the page will not be valid without it.
Checkout at this link an example: example.
<img src="http://www.1341234123412312/ic_mountain.jpg" alt="Image not found" style="width:200px;height:128px"/>
alt isn't a tag, it's an attribute. It doesn't specify an alternate image, it defines the alternate text of an image if it cannot be displayed. In most cases it's used as hover-over text.
Like henriquedsg89 mentioned the alt ATTRIBUTE is used to display alternate text. An example of it's purpose would be if a blind person can't see the photos. Instead the browser will read the alt attribute out loud.
alt is attribute, and used to display the image description. if image is not displayed because of some case.
<img src="/img.jpg" alt="Image not found">

How do I solve this issue in IE7?

When I am testing my page in IE7, all the image have a tooltip corresponding to the text of the alt in the image tag..
<img src="Myimage.jpg" alt="No pic" />
When I hover my mouse on the displayed pic in IE7, I get a tooltip "No pic" corresponding to the text of the alt .How do I fix this ?
IE6/7 treats the alt attribute as though it was a title attribute - but only if there's no actual title attribute set.
You can workaround it with a blank title:
<img src="Myimage.jpg" alt="No pic" title="" />
You can try adding an empty title tag
<img src="image.jpg" alt="nopic" title="" />
The answer has been posted already (empty title tag).
However, (in reference to one of the answers) alts are supposed to describe the image for 508 compliance reasons and if the image doesn't show up, so you should change the alt text to describe your picture.
I would have made a comment on the original post but SO doesn't allow me to yet.
The actual question here is why are you using alt the way you are? If your image is simply decorative, you should have an empty alt attribute. look at the W3CS definition of the alt attribute.
http://www.w3.org/QA/Tips/altAttribute
On this occasion is suspect youd actually want:
<img src="Myimage.jpg" alt="" />