Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > CSS

  • Print
  • + Share This
  • 💬 Discuss
Like this article? We recommend

Like this article? We recommend

5. img Element Errors

Two of the most common problems found when validating Web documents relate to the img element. The first of the two is a really disturbing issue: the lack of an alt attribute. The importance of alt attributes for accessibility and usability has been a known factor since before accessibility and usability became subsets of web design. Why, oh why, then, is it still one of the most commonly made errors? Fix it simply by ensuring that all your images have the alt attribute in place.

The second common problem with img elements is the use of the presentational border attribute. This is a deprecated attribute in favor of style sheets. You can turn off all borders on images by simply adding this rule to your style sheet:

img {
       border: 0;
}

Of course, you may have more complex needs and require borders on some images and not others. Using a range of CSS selector types or creating special classes, you can customize border properties for images as you see fit. Just leave the border attribute out of the img element and you'll be good to go.

  • + Share This
  • 🔖 Save To Your Account

Discussions

comments powered by Disqus