HTML Academy
Image dimensions
Links and images12/17
Back to the list of tasks
  • 1. What is a link? The a tag
  • 2. Relative addresses
  • 3. Absolute addresses
  • 4. Links to files
  • 5. An in-page link
  • 6. The img tag for images
  • 7. Image formats, SVG format
  • 8. JPEG format
  • 9. PNG format
  • 10. GIF format
  • 11. Image dimensions
  • 12. alt attribute
  • 13. Image link
  • 14. The figure and figcaption tags for illustrations and captions
  • 15. Links without href and the title attribute
  • 16. Summary of “Links and Images”
  • 17. Test: Cat tours travel agency gallery
Image link
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

alt attribute

Now the images are the right size, but Muffin is in a hurry for a business meeting in Moscow and is traveling on the Sapsan high speed train right now. There were some problems with the Internet, and the images did not finish loading, so he didn’t know what they were supposed to show.

HTML provides an attribute for an image’s text alternative. This text can appear when the image fails to load. It also helps people who cannot see the image, including those using a screen reader. This software can read page content and image text alternatives aloud. Useful alternative text makes the page’s information available even when the image itself cannot be seen.

The alternate text for the image is assigned using the attribute alt. For example:

<img src="cat.png" alt="A cat that walks by himself">

Now visitors won’t be left in the dark if an image fails to load.

Give informative images useful alt text. For purely decorative images, use an empty alt="".

Shall we give it a try?

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>The website of a beginning coder</title> <link rel="stylesheet" href="style.css"> </head> <body> <header> <p>Blog</p> <nav> <a href="index.html">Return to home</a> </nav> </header> <main> <article> <h1>Day Fourteen. A New Format</h1> <p>Yesterday, I found the right format for my avatar and added the image to my blog. I love how it looks! I decided to make a cheat sheet to remember the other image formats and what each one is used for.</p> <p>Here is my first GIF:</p> <!-- Add the alternate text for the image below --> <img src="files/gifka.gif" width="250" height="120"> <p>Here is a PNG image:</p> <!-- Add the alternate text for the image below --> <img src="files/portrait.png" height="250"> <p>For example, here is a JPEG image:</p> <!-- Add the alternate text for the image below --> <img src="files/instructor-muffin.jpg" width="250"> </article> <aside> Your ad could go here </aside> </main> <footer> Website footer </footer> </body> </html>
CSS
body { padding: 0 30px; font-size: 14px; line-height: 22px; font-family: "Georgia", serif; color: #222222; } h1 { font-size: 20px; line-height: normal; } aside { margin: 20px 0; color: #c4c4c4; } a[href] { color: #0099ef; text-decoration-line: underline; }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. Add the alternate text alt="GIF animation" to the first image.
    2. Now add the attribute alt with the value Cat portrait to the second image.
    3. Add the alternate text Instructor Muffin to the third image.
    4. Stop the second image from loading by removing its src attribute.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2026

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.