question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Alt attribute in img not recognized

See original GitHub issue

Challenge Name

Add Images to your Website

Issue Description

Tests do not recognize the alt attribute in the img element (see code below). I think it has something to do with the hyphen? Seems to work fine with an alt that doesn’t have it.

Browser Information

  • Browser Name, Version: Chrome 61.0.3163.100
  • Operating System: Windows 10
  • Mobile, Desktop, or Tablet: Desktop

Your Code


<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img src="https://bit.ly/fcc-relaxing-cat" alt="Cute upside-down kitten. ">

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

Screenshot

fcc

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
username1001commented, Oct 29, 2017

@thefifthisa I did some more digging because I had the same questions as you after reading your issue. It seems that alt attributes should not use hyphens, and the reason behind this is SEO i.e. someone isn’t going to do a search for ‘cat-image’, rather they’ll search ‘cat image’.

I think it should still pass the test, so you’re right, the issue may be with FCC; though, I’m not an expert and would love to hear someone else’s explanation.

0reactions
raisedadeadcommented, Dec 13, 2017

@angelfeliz

Thanks for your interest in fixing. I think we do not need italicizing here.

Lets keep it like so;

All img elements must have an alt attribute. The text inside an alt attribute is used for screen readers to improve accessibility and is displayed if the image fails to load.

Ideally the alt attribute should not contain special chars unless needed.

That said, you would also have to work on the tests that are failing for special chars.

Happy coding!

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML img, alt="" isnt working
Im using some icons on my website and in general most of the people who play this game know the icons but in...
Read more >
Why an HTML image alt text doesn't show on hover
Reasons why an HTML image alt text does not show when hovering in Firefox, Chrome and does show in Internet Explorer with examples....
Read more >
Img Alt Attribute Not Appearing in Sourcecode
Hi all- I inherited a site with an older theme and I've been working on getting its accessibility up to speed. I entered...
Read more >
"alt" attribute not working - MSDN
Hi, I am using Windows 8.1 with IE 11 and find that the "alt" attribute in images is not displaying the text that...
Read more >
HTMLImageElement.alt - Web APIs | MDN
A string which contains the alternate text to display when the image is not loaded or for use by assistive devices. The alt...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found