Writing good "alt" content? [closed] - html

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
What is it the best practice with regards the alt attribute of images?
For example, say I have an image with a caption that says "We look after our staff" and the accompanying image is a picture of a man looking out of a van windows towards the camera, for the alt content should I have something like:
"We look after our staff" (A copy of the image caption)
OR
"A picture of a man looking out of a van windows towards the camera" (A description of the image)

Taken from the w3 spec, reworded;
There is no "wrong" or "right" way of writing alt tags, as it is relative to the context. For example, take the following scenario; on your site, the end user is asked to pick his favourite colour:
The alt tags would be as follows:
<ul>
<li><img src="red.jpeg" alt="Red"></li>
<li><img src="green.jpeg" alt="Green"></li>
<li><img src="blue.jpeg" alt="Blue"></li>
</ul>
A second scenario is if you had a logo which in turn links through to the website, the alt tag should be a description of the link:
A well written alt tag would be:
<a href="http://w3.org">
<img src="images/w3c_home.png" width="72" height="48" alt="W3C web site">
</a>
More applicable for YOUR scenario would be the following examples.
Here is an example of an image closely related to the subject matter of the page content but not directly discussed. An image of a painting inspired by a poem, on a page reciting that poem. The following snippet shows an example. The image is a painting titled the "Lady of Shallot", it is inspired by the poem and its subject matter is derived from the poem. Therefore it is strongly recommended that a text alternative is provided. There is a short description of the content of the image in the alt attribute and a link below the image to a longer description located at the bottom of the document. At the end of the longer description there is also a link to further information about the painting.
Which should have the following code for the alt text
<header><h1>The Lady of Shalott</h1>
<h2>A poem by Alfred Lord Tennyson</h2></header>
<img src="shalott.jpeg" alt="Painting of a young woman with long hair, sitting in a wooden boat. ">
<p>Description of the painting.</p>
<!-- Full Recitation of Alfred, Lord Tennyson's Poem. -->
...
...
...
<p id="des">The woman in the painting is wearing a flowing white dress. A large piece of intricately
patterned fabric is draped over the side. In her right hand she holds the chain mooring the boat. Her expression
is mournful. She stares at a crucifix lying in front of her. Beside it are three candles. Two have blown out.
Further information about the painting.</p>
However.... sometimes an alt tag can be left out all together. For example, if you had the above image with a contextual description relative to the image on the page directly below:
Join us for our medieval theme nights every Friday at Boaters Bar, on
the riverside, Kingston upon Thames.
For the above example, either of the following solutions would be conforming:
<p><img src="shalott.jpeg" alt=""></p>
<p>Join us for our medieval theme nights every Friday at
Boaters Bar,on the riverside, Kingston upon Thames.</p>
Or
<p><img src="shalott.jpeg" alt="Painting of a woman in a white flowing dress, sitting in a small boat."></p>
<p>Join us for our medieval theme nights every Friday at Boaters Bar,
on the riverside, Kingston upon Thames.</p>

Extract from w3.org
When an image contains words that are important to understanding the
content, the alt text should include those words. This will allow the
alt text to play the same function on the page as the image. Note that
it does not necessarily describe the visual characteristics of the
image itself but must convey the same meaning as the image.
Example 1
An image on a Website provides a link to a free newsletter. The image
contains the text "Free newsletter. Get free recipes, news, and more.
Learn more." The alt text matches the text in the image.
Example 2
An image on a Web site depicts the floor plan of a building. The image
is an image map with each room an interactive map area. The alt text
is "The building's floor plan. Select a room for more information
about the purpose or content of the room." The instruction to "select
a room" indicates that the image is interactive.
http://www.w3.org/TR/WCAG20-TECHS/H37

Warning: this answer is rather subjective.
I use this attribute especially at images having a special function. For example a image of a disk on which the user can click for saving something. Then the value of alt would be "save".
But I don't think you should give a description of every picture. Just say "gallery image" or something like this.

Remember, the alt is for the text replacement for the imagine.
Many cases, I leave have alt = "" because there is no text that would replace that imagine.
Other times, just a single character is best:
<img src="fancy_bullet_point.gif" alt="*">
Just remember the basic rule of thumb: If you did not have the image, what would you put there instead?

Related

How can i verify the correct usage of an alt text with a tag

Here is the alt text I am trying to verify:
<a class="module-List-module-link—CtkbR—" href="/first/2041" alt="text">sample text (ABC)</a>
The original html snippet is:
<a class="module-List-module-link—CtkbR—" href="/first/2041">sample text (ABC)</a>
I only added the alt="text" to make it 508 compliant. My question is: Is that valid?
I am taking my cue from:
<article>
<a href="news.html">
<h3>Budget Debate Continues in Parliament</h3>
<p class="subhead"><img class="alertimg" src="alerticon.png" alt="Breaking News" height="30" width="30">Members of Parliament continued vigorous debate on three challenging issues surrounding the upcoming year's budget.</p>
<p>Read more</p>
</a>
</article>
reference: the WCAG section
When i scan the page using Compliance Sheriff, i get an issue:
Anchor element does not have alternative text which describes purpose of the link
for :
<a class="module-List-module-link—CtkbR—" href="/first/2041">sample text (ABC)</a>
There is no correct usage of the alt attribute for an <a> element.
alt is used for images when the image cannot be loaded or understood by a user (e.g. because the image file didn't load, the browser is text only, or the user is blind).

How to solve image colors fading when uploaded in a html file

I added some images to my website and the colors in them faded out.
here is the section where I am adding one of the images in the HTML
<section id="two" class="spotlight style2 right">
<div class="image fit main"><img src="images/1111.jpg" alt="" /></div>
<div class="content">
<header>
<h2>Courses & Projects</h2>
<p>For Adults and Students</p>
</header>
<p>Robone team developed their own educational curriculum based on studying students’ behavior, especially students’ stress arousals and their effects on students’ understanding.</p>
<p>One of the most unique factors of Robone is their curriculum, which is updated quarterly based on technology updates and facilities.</p>
<p>. Moreover, Robone team design their curriculum based on a combination between international advanced course text books and elementary courses.</p>
<ul class="actions">
<li>Learn More</li>
</ul>
</div>
Next
</section>
I tried using different extensions of the image (.jpg, .jpeg, .png) but still the colors fade out.
I would comment rather than answer, but I don't have enough 'reputation'...
Try looking at style definition for .image and see if there's an opacity setting less than value of 1.
I can only guess without CSS to look at.
The problem you are (probably) facing is that your image has a (not supported) color profile. You should first convert your image to a sRGB image (safe RGB) in Photoshop or a similar program. You might experience the same 'fading' while converting. When you correct that and save as sRGB your image will show up exactly as intended. Any other color profile suffers from interpretation errors by your webbrowser/computer/device (this is partly why 'Save For Web' is invented).
sRGB: the color profile used by most web browsers to display images on the web.
Some background info, and
some more...

WCAG compatible removal of image alt text from google search

Since we optimized our HTML markup for WCAG 2.0, we have a lot of (sometimes ugly) image descriptions in the google search results including our google site search. Does anyone knows a way to hide them from the result descriptions?
Example:
<h1>fiscal authority</h1>
<img src="..." alt="The image shows the entrance of the fiscal authority" />
<p>
The fiscal authority is...
</p>
Search result:
Fiscal authority
----------------
The Image shows the entrance of the fiscal authority The fiscal authority is...
We cannot...
...move the picture outside of the content
...provide an empty alt="" attribute
...use javascript to insert the image or the alt text after rendering
see http://www.w3.org/TR/WCAG20-TECHS/H37.html for further details
A visitor using a screen reader should get the alt text. I believe this should be a common problem with WCAG and I like to hear how other developers solved this issue?
WCAG Technique H67 clearly states that:
The purpose of this technique is to show how images can be marked so that they can be ignored by Assistive Technology.
If no title attribute is used, and the alt text is set to null (i.e. alt="") it indicates to assistive technology that the image can be safely ignored.
Given that BITV very clearly follows the WCAG standard, then an empty alt tag for a purely decorative image (like a doorway) is perfectly fine. It is important to recognise that WCAG is a set of highly subjective recommendations and techniques. Many tests are non-automatable, so if you can appropriately argue compliance than that is enough.
Consider the following:
<h1>fiscal authority</h1>
<img src="doorway.bmp" alt="" />
<p>
The fiscal authority is an institute for authorising fiduciary claims.
</p>
Here the existence of the doorway is purely a decoration.
And contrast with:
<h1>Doorway</h1>
<img src="doorway.bmp" alt="A Victorian-style doorway with beveled edging." />
<p>
A doorway is a hole cut in a wall to allow passage between rooms.
</p>
This is an image of a doorway that adds context to the text (although the image might be better placed).

Acceptable to include a definition list within a <figcaption> tag?

Background
I am using Swiper to create a slider for a restaurant website and I would like to code it as semantically as possible. To give you an idea of the content, each slide has four main features:
Background image
Menu category (i.e. sandwiches)
Menu item
Menu item description
If you need a visual (and an appetite):
My Solution
This was the most semantic way I could think of to code it:
<figure class="swiper-slide">
<img src="img/hammin-it-up.jpg" alt="" />
<figcaption>
<strong class="slider-menu-category">Sandwiches</strong>
<dl class="slider-menu-item">
<dt>Hammin' It Up</dt>
<dd>Fontina Cheese & Blackforest Ham grilled on Texas Toast</dd>
</dl>
</figcaption>
</figure>
My Question/s
Is it semantically friendly and w3-OK to use a <dl> within a <figcaption> tag?
Is there a more semantic way to show the slide "title" (aka category) than using a class? I realize this is a separate question, but it's related and I couldn't cram all that into the post title...
My Research
I could not find a site with an exact match to what I did, but I found some that were close:
MDN has some examples with a <cite> tag inside a <figcaption>.
HTML5 Doctor has an <a> and <code> inside the same.
An S.O. user posted an indirectly related question, but I noticed within their markup some <p> tags inside a <figcaption>.
w3.org indicates nothing suggesting my method was incorrect, so I am semi-sure it's fine, but any feedback would be appreciated.
Yes, dl is allowed inside of figure/figcaption: dl is flow content, and figure/figcaption expect flow content according to their content model.
However, I don’t think it’s the best choice in your specific example.
The dl doesn’t really add anything to understanding the content of this figure. It would be appropriate if there were several name-value pairs (e.g., "Price", "Ingredients" etc.), but what you currently have is just a title and a description.
The strong element doesn’t seem to be used according to its definition ("strong importance, seriousness, or urgency") here.
And I also think that the category/title/description isn’t really a caption for the photograph in this case; to me, it seems these 4 elements should be on the same level, so to say. But this is open for interpretation and also depends on the context where this slideshow will be shown.
Instead of using figure, I think that each menu item should be an article. This choice enables the use of headings and header elements:
<article>
<img src="" alt="" />
<header>
<div>Sandwiches</div>
<h1>Hammin' It Up</h1>
</header>
<p>Fontina Cheese & Blackforest Ham grilled on Texas Toast</p>
</article>
use <div> .. </div> for everything , <figcaption> is allowed with HTML5
sticking with div's will be compatable with any browser on any device. You can use a title attribute if you'd like. You can also have any attribute as long as it starts with data-
and example would be <div class="exampleClass" data-title="My Title" data-info="My other info">

Align two images with text [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want to align the two pictures at the top of this site http://paulcwebster.com
with the text beside them.
So far, I was able to align two images beside each other, but I have the problem of:
1) The text not having any space between the images.
2) The text being too short or too long for the images on different browsers.
3) Not having the text size match the site of the pictures
4) Not being able to move the text "Recent Publications" to the left after (I've triend align="left" and putting it in it's own div)
Here is my code:
<div >
<img src="gfx/FrontImage1.jpg" width="180" height="180" alt="Image1" style="float:left">
<img src="gfx/FrontImage3.jpg" width="180" height="180" alt="Image2" style="float:left">
<span ><p>Paul Christopher Webster is a freelance writer and documentary film director based in Toronto, Canada. He has reported from 20 countries since 1992.</p>
Paul's work in film has appeared on the Arte, BBC, CBC, Deutsche Welle, Discovery, National Geographic, Slice, SWR and Vision Television networks. His work as a writer has been published in dozens of magazines, journals and newspapers across Canada, the U.S, and Europe. </p>
<p>He has won four national magazine awards for his writing, and Tier One Journalism Award from the Canadian Institutes of Health Research. His work on documentary films has garnered awards from the Canadian Association of Journalists, Hot Docs, the Canadian Academy of Film and Television, and PARISCIENCE, the international festival of scientific films.
<p>Paul’s work focuses on themes in business, science, and politics. For samples of his work in these categories, please click on the links to articles below.
</span>
</div>
First, I recommend restructuring your HTML markup. Put a <div> or other block-level element around each of the elements you want to control. Something like this:
<div class="container">
<div class="photos">
<img src="gfx/FrontImage1.jpg" width="180" height="180" alt="Image1">
<img src="gfx/FrontImage3.jpg" width="180" height="180" alt="Image2">
</div>
<div class="text">
Your text goes here...
</div>
</div>
Then, write some CSS to control these elements the way you want:
.container {
overflow:hidden; // this keeps the floated objects inside the container
padding:5px;
border:solid 1px black;
}
.container .photos {
float:left;
margin-right:10px; // this puts some padding to the right of the photos
}
I am assuming here that you know how to include a stylesheet to apply the above CSS to your page. This should solve problems 1) and 4). There really isn't any way to ensure that the size of the text always matches the height of the images, as it can flow and change, depending on the width of the browser, and the font size that the viewer is using, so I don't see a way to solve problems 2) and 3).
Note: I see that you are using a <span> element to contain your <p> elements. This is invalid markup, since a <span> is an inline element, and a <p> is a block level element. Inline elements cannot contain block level elements.