HTML Academy
The figure and figcaption tags for illustrations and captions
Links and images15/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
Summary of “Links and Images”
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Links without href and the title attribute

The photo pages contain links that lead users to the previous and next photo pages. What should we do with this link, for example, on the last photo page? After all, there is no next photo in this case. You can delete the entire link, or you can do something else.

An <a> element without href is a placeholder rather than an active link. Adding href makes it a link to a destination. A placeholder can be useful when a navigation item has no destination, such as “Next” on the last photo, or when an item represents the current page:

<nav>
  <ul>
    <li><a>Page 1</a></li>
    <li><a href="2">Page 2</a></li>
    <li><a href="3">Page 3</a></li>
  </ul>
</nav>

The title attribute can provide an additional hint about an element, such as why a navigation item has no destination. Many desktop browsers show this hint as a tooltip on hover. Keep important explanations visible on the page: title tooltips are not reliably available to keyboard, touch or screen-reader users. For example:

<a title="You are viewing the first photo, so there is no previous photo.">Back</a>

In many desktop browsers, the tooltip appears when you hold the pointer over the element for a moment.

Now let’s modify the navigation on the last page of the gallery.

After completing this step, you can download an archive of the Website of a Beginning Coder we have built.

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="day-15.html">Return to entry</a> </nav> </header> <main> <article> <figure> <img src="files/muffin-3.jpg" width="486" height="315" alt="Muffin"> <figcaption>Muffin congratulates us on how much we’ve learned.</figcaption> </figure> <nav class="pagination"> <a href="photo-2.html">&lt; Back</a> <!-- Modify this link --> <a href="#">Forward &gt;</a> </nav> </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; } nav { color: #888888; } aside { margin: 20px 0; color: #c4c4c4; } a[href] { color: #0099ef; text-decoration-line: underline; } figure { margin-left: 0; margin-right: 0; } figure img { vertical-align: middle; border: 8px solid rgb(202, 224, 248); } figcaption { width: 502px; padding-bottom: 8px; font-size: 12px; letter-spacing: 0.02em; font-style: italic; text-align: center; background-color: rgb(202, 224, 248); } .pagination a { display: inline-block; margin-right: 30px; margin-bottom: 15px; } .pagination { text-align: center; }

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. Remove the attribute href from the link Forward.
    2. Then add the attribute title with the text This is the last photo in the gallery to it.

    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.