HTML Academy
Image link
Links and images14/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
Links without href and the title attribute
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

The figure and figcaption tags for illustrations and captions

Each thumbnail in our selfie gallery links to a separate photo page containing a full-size image and a caption. The photo and its caption form a self-contained unit that we could reuse elsewhere in the blog. How should we mark up that unit?

The <figure> tag is suited to this kind of self-contained content. It can group an illustration with an optional caption as one unit. The content could be an image, graph, code example or table that is referred to from the surrounding text.

A figure can have a caption that explains its content. Use <figcaption> to mark up that caption, placing it as the first or last element inside <figure>. For example:

<figure>
  Graph, image, diagram or code
  <figcaption>Caption for the content</figcaption>
</figure>

Let’s mark up the photo in our gallery using <figure>.

Browsers add margins to figure by default, so we added styles for figure and figcaption. You can view them in the style.css tab.

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> <!-- Wrap the image below using the figure tag --> <img src="files/muffin-1.jpg" width="486" height="315" alt="Muffin"> <nav class="pagination"> <a href="#">&lt; Back</a> <a href="photo-2.html">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; } 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. Wrap the image using the figure tag.
    2. Inside the figure, add a figcaption containing The vigilant instructor, Muffin, maintains order.

    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.