diff --git a/tutorials/html/05-images/accessible-images.mdx b/tutorials/html/05-images/accessible-images.mdx
index b63da577c..1b0868b91 100644
--- a/tutorials/html/05-images/accessible-images.mdx
+++ b/tutorials/html/05-images/accessible-images.mdx
@@ -1,16 +1,512 @@
---
-id: accessible-images
-title: "Best Practices for Accessible Web Images"
+id: html-accessible-images
+title: "Accessible Images in HTML"
sidebar_label: "Accessible Images"
sidebar_position: 11
slug: /html/images/accessible-images
-description: "Learn how to make visual media fully accessible with decorative alt semantics, complex image descriptions, SVG accessibility, and ARIA roles."
+description: "Learn how to make every image in your HTML pages accessible. Decide between informative, decorative, functional, and complex images, write useful alt text, handle text in images, linked images, SVG, animated GIFs, and test with real tools on CodeHarborHub."
keywords:
- accessible images HTML
- - empty alt attribute decorative
- - SVG accessibility aria
- - web accessibility WCAG images
+ - HTML alt text best practices
+ - decorative images alt empty
+ - functional images links buttons
+ - complex images long description
+ - text in images accessibility
+ - SVG accessibility role img
+ - prefers-reduced-motion GIF
+ - web accessibility images
+ - WCAG non-text content
+ - screen reader images
+ - learn HTML images
- CodeHarborHub HTML
-authors: [ajay-dhangar]
-tags: [html, accessibility, wcag, a11y]
----
\ No newline at end of file
+tags: [html, web-development, beginner, images, accessibility, alt-text, wcag, frontend]
+---
+
+export const sample = "data:image/svg+xml;utf8," + encodeURIComponent(" ");
+
+export const searchIcon = "data:image/svg+xml;utf8," + encodeURIComponent(" ");
+
+Imagine opening your favorite website, but every picture on it is invisible. Menus are just empty boxes, charts are blank, and the photos have vanished. For millions of people, this is not a thought experiment. Some are blind and use screen readers. Some have low vision. Some are on a slow mobile connection in a remote area, where images never finish loading. Some simply turned images off to save data.
+
+Accessible images make sure that **everyone gets the same information and the same abilities**, whether or not they can see the picture. The good news: you already know most of the tools. This final lesson of the section shows you how to **decide** what each image needs, and how to do it well.
+
+
+
+
+## What You Will Learn
+
+- The four jobs an image can have, and how each changes your `alt` text
+- How to write `alt` text that is short, useful, and honest
+- When to use an empty `alt=""` and why it is not a mistake
+- How to handle linked images, buttons, icons, and text in images
+- How to describe charts and other complex images
+- How to make SVG and animated images accessible
+- How to test your work with free tools
+
+## Why Accessibility Is Everyone's Job
+
+Accessible images are not only a "nice extra" for a small group. They are part of the rules in many countries, and part of the international standard called **WCAG** (Web Content Accessibility Guidelines). The first rule in that standard is simple: *every non-text item needs a text alternative that serves the same purpose.*
+
+They also help everyone else:
+
+- **Slow connections:** When an image fails to load, the `alt` text appears in its place.
+- **Search engines:** Google reads `alt` text to understand your images.
+- **Voice assistants and translation tools:** They read text, not pixels.
+- **Bright sunlight, broken screens, old devices:** Text still gets through.
+
+:::info The core idea
+The right `alt` text depends on the **purpose** of the image in that place, not only on what the image shows. The same photo can need different `alt` text on two different pages.
+:::
+
+## Step One: Ask "What Is This Image For?"
+
+Before you type a single word of `alt`, ask what job the image does. Almost every image fits one of these four jobs.
+
+| Job | What it does | What `alt` should be |
+| :-- | :-- | :-- |
+| **Informative** | Adds meaning or information | A short description of the meaning |
+| **Decorative** | Only for looks, adds nothing new | Empty: `alt=""` |
+| **Functional** | Is inside a link or button, so it does something | Describe the **action**, not the picture |
+| **Complex** | Contains a lot of data (chart, map, diagram) | A short summary, plus a longer description nearby |
+
+Let's look at each one.
+
+## 1. Informative Images
+
+An informative image adds something the text does not already say. Write a short description of what matters.
+
+
+
+
+```html title="index.html"
+
+```
+
+
+
+
+
+<>
+
+>
+
+
+
+
+
+### Tips for Writing Good `alt` Text
+
+1. **Be concise.** One short sentence is usually enough. A good guide is under 125 characters, but meaning matters more than counting.
+2. **Describe what matters in context.** On a travel blog, "A white sailboat at sea" works. On a sailing-shop product page, the boat model and rig type might matter.
+3. **Do not start with "image of" or "picture of."** Screen readers already announce that it is an image.
+4. **Skip the file name.** `alt="IMG_20250311.jpg"` helps nobody.
+5. **Do not stuff keywords.** `alt="boat boat sailing boat buy boat cheap"` is bad for people and for search engines.
+6. **Include text that is in the picture,** if that text matters.
+7. **End with a period** if it is a full sentence. It gives screen readers a natural pause.
+
+
+
+
+```html
+
+
+
+```
+
+
+
+
+```html
+
+
+
+```
+
+
+
+
+## 2. Decorative Images
+
+Some images are purely for style: a divider swirl, a background texture, a pretty shape beside a heading. They add no information. If a screen reader announced each one, it would only create noise.
+
+For these, use an **empty** `alt` attribute:
+
+```html
+
+```
+
+With `alt=""`, screen readers skip the image completely.
+
+:::warning Empty alt is not the same as no alt
+- `alt=""` says: "I thought about it. This image is decorative." Screen readers skip it. ✅
+- **No `alt` attribute at all** says: "I forgot." Some screen readers then read out the file name, like "swirl dot s v g." ❌
+
+Always include the attribute, even when it is empty.
+:::
+
+### The Even Better Option: CSS Backgrounds
+
+If an image is purely decoration, ask whether it belongs in HTML at all. Style belongs in CSS, so a decorative image can often be a background.
+
+```css
+.hero {
+ background-image: url("images/waves.svg");
+ background-size: cover;
+}
+```
+
+Images added through CSS are ignored by screen readers, which is exactly what you want for decoration. But never put important information in a CSS background. There is no way to give it `alt` text.
+
+## 3. Functional Images
+
+A **functional image** is inside a link or a button. Clicking it *does* something. Here, `alt` must describe the **action or destination**, not the appearance.
+
+
+
+
+```html title="index.html"
+
+
+
+
+
+
+
+
+
+```
+
+
+
+
+
+<>
+
+
+
+>
+
+
+
+
+
+A screen reader announces the first example as "Search, button." That is exactly what a user needs. If the `alt` said "magnifying glass," they would hear "magnifying glass, button" and have to guess.
+
+| Image | Weak `alt` | Strong `alt` |
+| :-- | :-- | :-- |
+| Magnifier icon in a search button | `magnifying glass` | `Search` |
+| Logo inside a home link | `logo` | `CodeHarborHub home` |
+| Printer icon in a button | `printer icon` | `Print this page` |
+| Arrow in a "next" link | `right arrow` | `Next lesson` |
+
+### When the Link Also Has Text
+
+If the link or button already has visible text, the icon beside it is decorative. Give it an empty `alt` so the label is not read twice.
+
+```html
+
+
+ Download the guide (PDF)
+
+```
+
+## 4. Complex Images
+
+Charts, maps, infographics, and diagrams hold more information than a single sentence can carry. One short `alt` cannot do the job, and a very long `alt` is hard to navigate.
+
+The pattern is simple:
+
+1. Put a **short summary** in `alt`: what it is, and the main point.
+2. Provide the **full information** in text nearby, such as a data table or a paragraph.
+
+
+
+
+```html title="index.html"
+
+
+ Monthly visitors, January to March.
+
+
+
+ Chart data as a table
+
+ Month Visitors
+ January 12,000
+ February 18,500
+ March 25,200
+
+
+```
+
+
+
+
+
+<>
+
+
+ Monthly visitors, January to March.
+
+
+
+ Chart data as a table
+
+
+ Month Visitors
+ January 12,000
+ February 18,500
+ March 25,200
+
+
+
+>
+
+
+
+
+
+Here a sample drawing stands in for the chart. In your project, `src` points to the real chart.
+
+The table is useful for **everyone**: a screen reader user can move through it cell by cell, and a sighted user can read exact numbers that a bar can only suggest. Accessible content often turns out to be better content.
+
+:::tip Linking the image to its long description
+You can also connect an image to a longer description on the same page with `aria-describedby`:
+
+```html
+
+
Visitors grew from 12,000 in January to 25,200 in March...
+```
+
+Screen readers will read the `alt` first and offer the longer description.
+:::
+
+## Text Inside Images
+
+Putting words inside a picture (a banner, a screenshot of a quote, a button drawn in an image editor) causes many problems:
+
+- Screen readers cannot read the words unless you repeat them in `alt`.
+- Text cannot be resized, translated, searched, or copied.
+- The words can turn blurry on a high-resolution screen.
+- Low-vision users cannot change the colors or the font.
+
+**The best solution is to use real HTML text** and style it with CSS. If you must keep text in an image (a logo, for example), repeat the exact words in `alt`.
+
+
+
+
+```html
+
+
+```
+
+
+
+
+```html
+
+
+
50% off all courses
+
Offer ends Sunday.
+
+```
+
+
+
+
+## SVG and Icons
+
+Inline SVG is a favorite for icons and charts because it scales perfectly. Like an image, it needs a text alternative when it carries meaning.
+
+
+
+
+```html
+
+ Warning
+
+
+```
+
+
+
+
+```html
+
+
+
+
+```
+
+
+
+
+- `role="img"` tells assistive tech to treat the SVG as one image.
+- `` plus `aria-labelledby` provides its name.
+- `aria-hidden="true"` hides an SVG that is only decoration (for example, an icon next to a text label).
+
+For an SVG loaded through ` `, use the `alt` attribute as usual.
+
+## Animated Images and Motion
+
+Animated GIFs and looping animations can distract people with attention difficulties. Fast flashing can even trigger seizures for people with photosensitive epilepsy.
+
+- **Avoid flashing more than three times per second.** This is a safety rule from WCAG.
+- **Give users control.** If something moves for more than five seconds, provide a way to pause it.
+- **Respect the "reduce motion" setting.** Many people turn this on in their operating system, and CSS can read it:
+
+```css
+@media (prefers-reduced-motion: reduce) {
+ .animated-banner {
+ animation: none;
+ }
+}
+```
+
+For a video-like animation, a real `` with controls is often better than a GIF. It can be paused, and it is usually far smaller in file size.
+
+## Color and Contrast
+
+Some images carry meaning only through color, such as a red dot for "error" and a green dot for "success." About 1 in 12 men has some form of color vision difference. Add a second clue: a shape, a pattern, or a text label.
+
+When text sits on top of an image, check the **contrast ratio**. WCAG asks for at least **4.5:1** for normal text and **3:1** for large text. A busy photo behind white text can fail in some areas. A semi-transparent dark overlay behind the text is an easy fix.
+
+## Quick Decision Guide
+
+Use this when you are unsure what to write.
+
+| Question | If yes | If no |
+| :-- | :-- | :-- |
+| Is the image inside a link or button? | Describe the **action** | Go to the next question |
+| Does it only decorate, or repeat nearby text? | `alt=""` | Go to the next question |
+| Does it hold lots of data? | Short `alt` plus a full text version | Go to the next question |
+| Does it contain important text? | Put the same words in `alt` | Describe the meaning in a short phrase |
+
+## Testing Your Images
+
+You do not need expensive tools. Try these in order:
+
+1. **Turn images off.** In your browser's developer tools or settings, block images and read your page. Does it still make sense?
+2. **Check with a screen reader.** NVDA (Windows, free), VoiceOver (built into macOS and iPhone), and TalkBack (Android) all work. Even five minutes of listening teaches a lot.
+3. **Run an automated checker.** Lighthouse (inside Chrome DevTools), axe DevTools, and WAVE will find missing `alt` attributes.
+4. **Read the `alt` text out loud, alone.** If it does not make sense without the picture, rewrite it.
+5. **Ask real users** when you can. No tool replaces their feedback.
+
+:::note Automated tools only catch about a third of the problems
+A checker can tell you if `alt` is *missing*, but not if it is *useful*. `alt="image"` passes the test, but helps nobody. Human judgment is the most important tool.
+:::
+
+## Global Audience Notes
+
+- **Write `alt` in the same language as the page.** If one image is in another language, mark the element with `lang`.
+- **Use plain, clear words.** Many of your readers use translation tools, and simple sentences translate best.
+- **Avoid culture-specific references** that need local knowledge to understand.
+- **Keep file sizes small.** In many regions, data is expensive and connections are slow. Accessible also means *reachable*.
+
+## Common Mistakes to Avoid
+
+1. **Missing `alt` attributes.** Always include one, even if empty.
+2. **Starting with "image of" or "photo of."** Screen readers already say "image."
+3. **Using the file name as `alt`.** It carries no meaning.
+4. **Describing the icon instead of the action.** Write "Search," not "magnifying glass."
+5. **Repeating the caption or nearby text** word for word.
+6. **Putting important text inside images** without matching `alt`.
+7. **Using `alt=""` on an informative image** just to pass a checker. This hides real content.
+8. **Stuffing keywords** into `alt` for search ranking.
+9. **Relying on color alone** to carry meaning.
+10. **Autoplaying, flashing animations** with no way to pause them.
+
+## Practice Time
+
+Take any page from your project, or build a small one, and try these:
+
+1. Add one informative image with a short, clear `alt`.
+2. Add one decorative image with `alt=""`.
+3. Add a search button with an icon, and give the icon an action-based `alt`.
+4. Add a link that has both an icon and a text label. Make the icon decorative.
+5. Create a "chart" figure with a short `alt` and a hidden data table inside ``.
+6. Replace one text-in-image banner with real HTML text and CSS.
+7. Add an inline SVG with `role="img"` and a ``, and another with `aria-hidden="true"`.
+8. Add a `prefers-reduced-motion` rule that stops one animation.
+9. Block images in your browser and read the page. Fix anything that no longer makes sense.
+10. Bonus: run Lighthouse and aim for a perfect accessibility score.
+
+
+
+
+## Quick Recap
+
+Click a question to check your answer.
+
+
+1. What are the four jobs an image can have?
+
+Informative, decorative, functional (inside a link or button), and complex (charts, maps, diagrams).
+
+
+
+
+2. When should you use `alt=""`?
+
+When an image is purely decorative or just repeats nearby text. The empty value tells screen readers to skip it.
+
+
+
+
+3. What is the difference between `alt=""` and no `alt` at all?
+
+`alt=""` is a deliberate choice that hides the image from assistive technology. A missing `alt` is an error, and some screen readers read out the file name instead.
+
+
+
+
+4. What should `alt` say for an icon inside a button?
+
+The action, such as "Search" or "Print this page," not a description of the icon.
+
+
+
+
+5. How do you make a complex chart accessible?
+
+Give it a short `alt` that names the chart and its main point, and provide the full data nearby as text or a table.
+
+
+
+
+6. How do you make an inline SVG accessible?
+
+Use `role="img"` with a `` (and `aria-labelledby`) when it has meaning, or `aria-hidden="true"` when it is only decoration.
+
+
+
+## Key Takeaways
+
+- Start every image with one question: **what is this image for?** The answer decides the `alt`.
+- Informative images get short, useful descriptions. Decorative images get `alt=""`. Functional images describe the action. Complex images get a summary plus full text.
+- Prefer real HTML text over text in images, and CSS backgrounds for pure decoration.
+- Make SVGs, animations, and color-based meaning accessible too.
+- Test by blocking images, listening with a screen reader, and running an automated checker. Then use your own judgment.
+- Accessible images are clearer, lighter, and kinder for everyone, wherever they are in the world.
+
+You have now finished the Images section: from the ` ` tag to responsive formats, lazy loading, captions, and accessibility. Head back to the [Images overview](/tutorials/html/images) to review the full path, or keep going with the next section of the HTML course.
\ No newline at end of file
diff --git a/tutorials/html/05-images/figure-and-figcaption.mdx b/tutorials/html/05-images/figure-and-figcaption.mdx
index 66f576226..d28d6ccf5 100644
--- a/tutorials/html/05-images/figure-and-figcaption.mdx
+++ b/tutorials/html/05-images/figure-and-figcaption.mdx
@@ -1,16 +1,495 @@
---
-id: figure-and-figcaption
-title: "Structuring Image Captions with figure and figcaption"
-sidebar_label: "Figure & Figcaption"
-sidebar_position: 8
+id: html-figure-and-figcaption
+title: "HTML figure and figcaption"
+sidebar_label: "Figure and Figcaption"
+sidebar_position: 10
slug: /html/images/figure-and-figcaption
-description: "Wrap self-contained media content with figure and provide semantic text captions using figcaption for clean document structure."
+description: "Learn how to use the HTML figure and figcaption elements to add captions to images, diagrams, code, quotes and tables. Understand captions versus alt text, numbering with CSS counters, credits and licenses, accessibility, styling, and common mistakes on CodeHarborHub."
keywords:
- - HTML figure element
- - figcaption element
- - image with caption HTML
- - semantic image wrapping
+ - HTML figure
+ - HTML figcaption
+ - image captions HTML
+ - figure vs img
+ - figcaption vs alt
+ - CSS counter figure numbering
+ - HTML figure code block
+ - HTML figure blockquote
+ - image credits license HTML
+ - accessible captions
+ - learn HTML images
- CodeHarborHub HTML
-authors: [ajay-dhangar]
-tags: [html, figure, semantics, typography]
----
\ No newline at end of file
+tags: [html, web-development, beginner, images, figure, figcaption, accessibility, frontend]
+---
+
+export const sample = "data:image/svg+xml;utf8," + encodeURIComponent(" ");
+
+Open a printed book or a magazine, and you will notice that pictures rarely stand alone. Underneath each one is a short line of text: "Figure 3. A fishing harbor at sunrise. Photo: A. Okafor." The picture and its caption belong together. If you moved the picture to another page, its caption would go with it.
+
+HTML has two elements for exactly this: ``, which holds the picture, and ``, which holds the caption. They are simple, but they carry real meaning: "this content is a self-contained unit, and this text describes it." In this lesson, you will learn how to use them well.
+
+
+
+
+## What You Will Learn
+
+- What `` and `` mean, and what you can put in them
+- How a caption differs from `alt` text
+- How to caption images, diagrams, code, quotes, and more
+- How to number figures automatically with CSS
+- How to give credit and show licenses
+- How to style figures and keep them accessible
+- Common mistakes, and how to avoid them
+
+## The Basics
+
+Wrap the image in a ``, and add a `` as the first or last child.
+
+
+
+
+```html title="index.html"
+
+
+
+ A sailboat leaves the harbor just after sunrise.
+
+
+```
+
+
+
+
+
+<>
+
+
+
+ A sailboat leaves the harbor just after sunrise.
+
+
+>
+
+
+
+
+
+The demo uses a small drawing built into the page. In your project, `src` points to a real photo.
+
+By default, browsers indent a `` with left and right margins (usually about 40 pixels) and show the caption as normal text below the picture. You can style both with CSS.
+
+## What the Elements Mean
+
+| Element | Meaning | Rules |
+| :-- | :-- | :-- |
+| `` | A **self-contained** piece of content, referred to from the main text, that could move elsewhere without changing the meaning of the text | Can hold images, diagrams, code, quotes, tables, videos, and more |
+| `` | The **caption or legend** for the figure | Must be the **first or last** child of ``. Only one per figure |
+
+The key idea is in "self-contained." If you removed the figure from the page and put it in an appendix, the main text would still make sense. That is why a decorative image is **not** a figure, but a chart that the text refers to is.
+
+:::tip A quick test
+Ask: "Does this content have a caption, and could it be moved to another place without breaking the sentence around it?" If yes, it is a good candidate for ``.
+:::
+
+## Caption, `alt`, and `title`: Three Different Jobs
+
+Beginners often mix these up. They answer different questions for different people.
+
+| | `alt` | `` | `title` |
+| :-- | :-- | :-- | :-- |
+| Question it answers | "What is in this image?" (the replacement for the picture) | "What should everyone know about this image?" (extra context) | "Anything else?" (a tooltip) |
+| Visible to | People who cannot see the image, and failed loads | **Everyone** | Mouse hover only |
+| Required? | Always | Optional | Optional, avoid |
+| Where | On the ` ` | Inside the `` | On the element |
+
+### How They Work Together
+
+If the caption already describes the picture, the `alt` text should not simply repeat it. A screen reader would read the same information twice.
+
+
+
+
+```html
+
+
+ A sailboat leaves the harbor just after sunrise.
+
+```
+
+
+
+
+```html
+
+
+
+ Morning departure from Port Meridian, the first day of the regatta.
+
+
+```
+
+The `alt` describes what is *seen*. The caption adds what is *known*: where, when, why.
+
+
+
+
+If the caption fully conveys the picture's meaning, a short `alt` is fine, or even `alt=""` in some cases. Just make sure a person who cannot see the image still gets the information once. You will go deeper in [Accessible Images](./accessible-images).
+
+## It Is Not Only for Images
+
+`` can wrap any content that has a caption and is referenced from the text.
+
+
+
+
+```html
+
+ console.log("Hello, harbor!");
+ Listing 1. Printing a message in JavaScript.
+
+```
+
+
+
+
+```html
+
+
+ The best way to learn to code is to build something you care about.
+
+
+ A tip often shared with beginners, from the CodeHarborHub forum .
+
+
+```
+
+You saw this pattern in [Quotations](/tutorials/html/text-content/quotations).
+
+
+
+
+```html
+
+
+ Course sign-ups by month
+ Month Sign-ups
+ March 120
+ June 250
+
+
+```
+
+A table has its own caption element, ``. Use it inside the `` instead of a ``.
+
+
+
+
+```html
+
+
+
+
+ Your browser does not support the video tag.
+
+ A two-minute introduction to the course.
+
+```
+
+
+
+
+## Several Images in One Figure
+
+A figure may hold more than one image if they share a single caption, such as a before-and-after comparison.
+
+```html title="before-after.html"
+
+
+
+ The school computer lab before (left) and after (right) its renovation.
+
+```
+
+If the images need **separate** captions, use separate figures. If they are a gallery of different pictures, give each its own ``.
+
+## Numbering Figures Automatically
+
+Books say "Figure 1," "Figure 2," and refer to them in the text. You can do the same with CSS counters, so you never renumber by hand.
+
+```css title="figure-numbers.css"
+body {
+ counter-reset: figure;
+}
+figure {
+ counter-increment: figure;
+}
+figcaption::before {
+ content: "Figure " counter(figure) ". ";
+ font-weight: 700;
+}
+```
+
+```html title="numbered.html"
+
+ As you can see in Figure 1 , the harbor is calm in the morning.
+
+
+
+
+ Fishing boats resting in the harbor at sunrise.
+
+```
+
+The caption now begins with "Figure 1." automatically. The `id` on the figure lets other parts of the page link to it, as you learned in [Internal Links](/tutorials/html/links-and-navigation/internal-links).
+
+:::info Text added by CSS
+Words added with `content` in CSS may not be announced by every screen reader, and they cannot be selected or translated like normal text. If the numbers matter, write "Figure 1." directly in the HTML. Use CSS counters for convenience, not for essential information.
+:::
+
+## Giving Credit and Showing Licenses
+
+Many images need a credit: who made it, where it came from, and the license that allows you to use it. The caption is the perfect place.
+
+```html title="credit.html"
+
+
+
+ A lighthouse at dusk.
+ Photo by A. Okafor ,
+ licensed under
+ CC BY 4.0 .
+
+
+```
+
+Tips for credits:
+
+- **Follow the license's rules exactly.** Some require the creator's name, a link to the license, or a note that you changed the image.
+- **Use full links** for the source and the license, so readers can check them.
+- **Keep the credit short,** and put the longer details on a separate credits page if needed.
+- **Never claim someone else's work as your own.**
+- **When in doubt, ask,** or choose a different image.
+
+## Styling Figures
+
+A small amount of CSS makes figures neat. Style the ` ` for sizing and the `` for text.
+
+
+
+
+```html title="styled-figure.html"
+
+
+
+
+ Fishing boats resting in the harbor at sunrise.
+
+```
+
+
+
+
+
+<>
+
+
+
+ Fishing boats resting in the harbor at sunrise.
+
+
+>
+
+
+
+
+
+### Caption on Top, or Beside
+
+A `` may go first, to appear above the content. For a side-by-side layout, use CSS Grid.
+
+```css
+figure.side {
+ display: grid;
+ grid-template-columns: 1fr 2fr;
+ gap: 1rem;
+ align-items: center;
+}
+```
+
+Keep the caption's contrast high and its text size readable. Gray text that is too light is hard for many people.
+
+## Accessibility and Global Readers
+
+- **Browsers connect the caption to the figure.** Many screen readers announce the figure as a group with its caption as its label. That is why a caption should make sense by itself.
+- **Do not repeat yourself.** The `alt` and the caption should not say the same thing.
+- **Write captions in the page's language,** and mark foreign names or terms with `lang`.
+- **Use plain words.** Many readers use a second language. Avoid idioms and long sentences.
+- **Right-to-left pages work as they are.** The caption follows the reading direction. Use logical CSS properties such as `margin-inline` if you set margins.
+- **Do not put important text only inside the image.** Say it in the caption or the text, where it can be searched and translated.
+- **Name the figure if there is no caption.** If a `` has no ``, give it an accessible name with `aria-label`, or reconsider whether it needs to be a figure at all.
+
+```html title="aria-label.html"
+
+
+
+```
+
+## When Not to Use ``
+
+Not every image needs a figure. Skip it when:
+
+- The image is **decoration** with `alt=""`.
+- The image is a **logo** or an **icon**.
+- The image is a **small inline picture** inside a sentence.
+- There is **no caption** and nothing refers to it.
+- The image is part of the **page design**, such as a background or banner.
+
+Using `` on everything adds noise for screen reader users, without adding meaning.
+
+## Choosing the Right Tool
+
+| You want to... | Use |
+| :-- | :-- |
+| Show a plain picture inside the flow of text | ` ` |
+| Add a visible caption that belongs to a picture, diagram, code, or quote | `` with `` |
+| Describe the image for people who cannot see it | `alt` on the ` ` |
+| Caption a table | `` inside the `` |
+| Group items in a gallery | A `` for each, in a list or grid |
+| Add a hover tooltip | `title`, used sparingly |
+
+## Common Mistakes
+
+### Mistake 1: Using `` for every image
+
+Reserve it for content that is self-contained and captioned.
+
+### Mistake 2: Placing `` in the wrong place
+
+It must be the **first or last** child of the ``, never in the middle.
+
+### Mistake 3: More than one ``
+
+A figure takes only one. Use separate figures for separate captions.
+
+### Mistake 4: Copying the caption into `alt`
+
+Screen reader users hear it twice. Make the two complement each other.
+
+### Mistake 5: Using `` outside a ``
+
+It has no meaning on its own.
+
+### Mistake 6: Skipping credits
+
+Always name the creator and the license when they are required.
+
+### Mistake 7: Using the caption for critical information that must stay hidden from no one but is not visible
+
+A caption is visible to everyone. Do not put in it things you do not want everyone to see.
+
+### Mistake 8: Forgetting default margins
+
+Browsers indent figures by default. If your layout looks off, set `margin` on `figure`.
+
+## Try It Yourself
+
+Here is a short project.
+
+1. Create `captions.html` with a heading **A Day at the Harbor**.
+2. Add three figures: a photo, a diagram or screenshot, and a short code listing.
+3. Write a caption for each, and a separate `alt` for the images that complements it, not repeats it.
+4. Add a CSS counter that numbers the captions as "Figure 1.", "Figure 2.", and so on.
+5. In the paragraph above the first figure, add a link to it using its `id`.
+6. Credit one image with a creator name and license link in its caption.
+7. Build a before-and-after figure with two images and one caption.
+8. Style the figures: a centered `max-width`, a rounded image, and a muted caption with good contrast.
+9. Bonus: caption the same photo in a second language, with the correct `lang` attribute.
+
+
+
+
+## Quick Recap
+
+Click a question to check your answer.
+
+
+1. What does `` represent?
+
+A self-contained piece of content, such as an image, diagram, code listing, or quote, that is referred to from the main text and could be moved elsewhere without changing its meaning.
+
+
+
+
+2. Where must `` go?
+
+Inside the ``, as its first or last child. There can be only one.
+
+
+
+
+3. How is a caption different from `alt` text?
+
+The `alt` text replaces the image for people who cannot see it. The caption is visible to everyone and adds context. They should complement each other, not repeat.
+
+
+
+
+4. How can you number figures automatically?
+
+With CSS counters: `counter-reset` on `body`, `counter-increment` on `figure`, and `counter()` in `figcaption::before`.
+
+
+
+
+5. What should you use to caption a table?
+
+The `` element inside the ``, instead of a ``.
+
+
+
+## Key Takeaways
+
+- `` groups self-contained content, and `` gives it a caption, first or last, one per figure.
+- A caption is for everyone. `alt` is for people who cannot see the image. Make them complement each other.
+- Figures can hold images, code, quotes, video, and more, but a table uses ``.
+- Use captions for credits and licenses, and CSS for numbering and styling.
+- Use `` only where it adds meaning, and write captions in plain, clear language for a global audience.
+
+Now your images have captions that stay with them. The last lesson brings everything together: how to make every image work for every visitor in [Accessible Images](./accessible-images).
\ No newline at end of file
diff --git a/tutorials/html/05-images/image-formats.mdx b/tutorials/html/05-images/image-formats.mdx
index b306b147b..8b814ce3c 100644
--- a/tutorials/html/05-images/image-formats.mdx
+++ b/tutorials/html/05-images/image-formats.mdx
@@ -1,16 +1,380 @@
---
-id: image-formats
-title: "Comparing Web Image Formats: JPEG, PNG, GIF, SVG, WebP, and AVIF"
+id: html-image-formats
+title: "Image Formats for the Web"
sidebar_label: "Image Formats"
-sidebar_position: 10
+sidebar_position: 5
slug: /html/images/image-formats
-description: "Understand the strengths, compression types, transparency support, and compatibility of modern web image formats like WebP, AVIF, and SVG."
+description: "Learn which image format to use on the web. Compare JPEG, PNG, GIF, WebP, AVIF and SVG, understand lossy and lossless compression, transparency and animation, browser support, optimization tools, metadata privacy, and how to choose the best format on CodeHarborHub."
keywords:
- - web image formats
- - WebP vs AVIF
- - SVG vector graphics
- - JPEG vs PNG lossy lossless
+ - image formats for web
+ - JPEG vs PNG vs WebP
+ - AVIF image format
+ - SVG images HTML
+ - GIF vs animated WebP
+ - lossy vs lossless compression
+ - raster vs vector images
+ - optimize images for web
+ - image compression tools
+ - favicon formats
+ - learn HTML images
- CodeHarborHub HTML
-authors: [ajay-dhangar]
-tags: [html, image-formats, webp, avif, performance]
----
\ No newline at end of file
+tags: [html, web-development, beginner, images, formats, performance, frontend]
+---
+
+export const sample = "data:image/svg+xml;utf8, ";
+
+Save the same photograph in different ways, and you can end up with files that differ in size by ten times, with almost no difference to the eye. On a page with twenty images, that gap decides whether your site loads in a second or in ten, and whether a visitor on a limited data plan can afford to open it.
+
+The **format** of an image file is the biggest choice you make about its weight and quality. This lesson explains the main formats in plain language, so you can pick the right one for each image, and know how to shrink files without spoiling them.
+
+
+
+
+## What You Will Learn
+
+- The difference between **raster** and **vector** images
+- What **lossy** and **lossless** compression mean
+- When to use JPEG, PNG, GIF, WebP, AVIF, and SVG
+- How transparency and animation fit in
+- Which formats browsers support, and how to offer fallbacks
+- How to compress and prepare images, including privacy tips
+- How to choose a format with a simple decision guide
+
+## Two Big Ideas
+
+### Raster vs Vector
+
+| | Raster | Vector |
+| :-- | :-- | :-- |
+| Made of | A grid of colored **pixels** | **Shapes and paths** described by math |
+| Zooming in | Gets blocky and blurry | Stays perfectly sharp |
+| Best for | Photographs, detailed pictures | Logos, icons, diagrams, simple illustrations |
+| File size | Grows with pixel count | Stays small for simple shapes |
+| Examples | JPEG, PNG, GIF, WebP, AVIF | SVG |
+
+A photo of a harbor has millions of subtle color changes, so it must be raster. A logo is a few clean shapes, so vector is ideal.
+
+### Lossy vs Lossless
+
+Compression makes files smaller by storing the picture more cleverly.
+
+| | Lossy | Lossless |
+| :-- | :-- | :-- |
+| What it does | **Throws away** details your eyes barely notice | Packs the data tighter, **losing nothing** |
+| File size | Much smaller | Smaller than raw, but larger than lossy |
+| Quality | Slightly reduced, adjustable | Identical to the original |
+| Best for | Photographs | Screenshots, sharp text, graphics with flat colors |
+| Repeated saving | Each save can lower quality further | No damage |
+
+:::tip Keep your originals
+Always keep the original, full-quality file somewhere safe. Make web copies from it. Once a lossy file has been compressed, the lost detail cannot come back.
+:::
+
+## The Formats
+
+### JPEG (`.jpg`, `.jpeg`)
+
+The classic format for photographs. It uses **lossy** compression and supports millions of colors.
+
+- **Good for:** photos with smooth gradients and many colors
+- **Not good for:** sharp text, line art, logos, or anything that needs a transparent background
+- **Transparency:** no
+- **Animation:** no
+- **Support:** every browser, ever
+
+### PNG (`.png`)
+
+A **lossless** format that keeps crisp edges and supports **transparency**.
+
+- **Good for:** screenshots, diagrams, images with text, graphics that need a see-through background
+- **Not good for:** large photographs, where files become heavy
+- **Transparency:** yes, with smooth edges
+- **Animation:** not in common use
+- **Support:** every browser
+
+### GIF (`.gif`)
+
+An old format limited to **256 colors**, famous for short looping animations.
+
+- **Good for:** very small, simple animations
+- **Not good for:** photos, or longer animations. Files are large and the color is poor
+- **Transparency:** yes, but with hard, jagged edges
+- **Animation:** yes
+- **Support:** every browser
+
+For most animations today, a short **video** or an animated **WebP** is far smaller than a GIF with better quality.
+
+### WebP (`.webp`)
+
+A modern format from Google that can be **lossy or lossless**, with transparency and animation in one format.
+
+- **Good for:** almost everything. It is often noticeably smaller than JPEG and PNG
+- **Transparency:** yes
+- **Animation:** yes
+- **Support:** all current major browsers
+
+### AVIF (`.avif`)
+
+A newer format based on a video codec. It often gives the **smallest files** for a given quality, with support for transparency and wide color.
+
+- **Good for:** photographs and graphics where every kilobyte counts
+- **Trade-off:** slower to create, and a little slower to decode on weak devices
+- **Transparency:** yes
+- **Animation:** yes, but less common
+- **Support:** current versions of the major browsers, though older ones may lack it, so offer a fallback
+
+### SVG (`.svg`)
+
+A **vector** format written in text (XML). It scales to any size without losing sharpness and can be styled and animated with CSS.
+
+- **Good for:** logos, icons, charts, illustrations with flat shapes
+- **Not good for:** photographs
+- **Transparency:** yes
+- **Animation:** yes, with CSS or script
+- **Support:** every modern browser
+
+
+
+
+```html title="svg-sizes.html"
+
+
+
+```
+
+
+
+
+
+<>
+ {' '}
+
+>
+
+
+
+
+
+The drawing above is itself an SVG. Notice how it stays crisp at both sizes. A raster image enlarged four times would look soft.
+
+:::warning Treat SVG files from strangers with care
+An SVG is text, and it can contain scripts. Loaded through ` `, scripts are blocked, so that is safe. Pasted directly into your page, or opened on its own, an untrusted SVG can run code. Only use SVGs from sources you trust, and sanitize any SVG that visitors upload.
+:::
+
+### Others You May Meet
+
+| Format | What it is | Advice |
+| :-- | :-- | :-- |
+| **ICO** | The classic favicon format | Fine for favicons, though a PNG or SVG favicon also works in modern browsers |
+| **HEIC / HEIF** | The default photo format on many phones | Convert to JPEG, WebP, or AVIF before using it on a web page |
+| **BMP, TIFF** | Large, uncompressed formats | Do not use them on the web |
+| **JPEG XL** | A newer format with strong features | Browser support is still limited, so check current support before relying on it |
+
+## Comparing the Main Formats
+
+| | JPEG | PNG | GIF | WebP | AVIF | SVG |
+| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
+| Type | Raster | Raster | Raster | Raster | Raster | Vector |
+| Compression | Lossy | Lossless | Lossless (256 colors) | Both | Both | Text |
+| Photos | Great | Heavy | Poor | Great | Great | No |
+| Sharp graphics and text | Poor | Great | Fair | Great | Great | Great |
+| Transparency | No | Yes | Basic | Yes | Yes | Yes |
+| Animation | No | No | Yes | Yes | Yes | Yes |
+| Typical file size | Medium | Large | Large | Small | Smallest | Tiny for simple shapes |
+| Browser support | Universal | Universal | Universal | Universal today | Wide, offer a fallback | Universal |
+
+Exact savings depend on the image, but as a rough guide, WebP is often around a quarter to a third smaller than a comparable JPEG, and AVIF is often smaller still. Always test your own images.
+
+## A Simple Decision Guide
+
+Ask these questions in order.
+
+1. **Is it a logo, icon, chart, or simple flat illustration?** Use **SVG**.
+2. **Is it a photograph or a picture with rich color?** Use **AVIF or WebP**, with a **JPEG** fallback.
+3. **Is it a screenshot, diagram, or picture with sharp text?** Use **WebP** (lossless) or **PNG**.
+4. **Does it need a transparent background and it is not a vector?** Use **WebP**, **AVIF**, or **PNG**.
+5. **Is it an animation?** Use a short **video** or an **animated WebP**. Avoid GIF unless it is tiny.
+
+| Your image | First choice | Fallback |
+| :-- | :-- | :-- |
+| Hero photo | AVIF or WebP | JPEG |
+| Product photo with a white background | WebP | JPEG |
+| Logo | SVG | PNG |
+| Icon set | SVG | PNG |
+| Chart | SVG, or WebP | PNG |
+| Screenshot | WebP | PNG |
+| Cutout with a transparent background | WebP | PNG |
+| Short looping clip | Video | Animated WebP |
+| Favicon | SVG or PNG | ICO |
+
+## Offering Fallbacks
+
+Not every browser understands every format. HTML gives you a clean way to offer several versions, and the browser picks the first one it can use. It is called the `` element, and you will study it in [Picture Element](./picture-element). Here is a preview.
+
+```html title="picture-preview.html"
+
+
+
+
+
+```
+
+A modern browser takes the AVIF. One that does not understand AVIF takes the WebP. The oldest takes the JPEG in the ` `, which also holds the `alt` text and the dimensions.
+
+## Preparing Images: A Practical Routine
+
+Picking a format is only part of the job. These steps make files light and tidy.
+
+1. **Resize first.** Decide the largest size the image will be shown at, then resize to about that (or twice that for sharp high-density screens). Never upload a 6000-pixel photo to show at 600.
+2. **Crop** to the part that matters.
+3. **Choose the format** with the guide above.
+4. **Compress.** For lossy photos, a quality between about 70 and 85 usually looks the same as the original to the eye, at a fraction of the size. Compare before you decide.
+5. **Strip extra data.** Photos often carry hidden **metadata** such as camera model, time, and even **GPS location**. Remove it before publishing.
+6. **Name the file clearly,** in lowercase with hyphens.
+7. **Check the result** in a browser, on a phone, at the real display size.
+
+### Tools to Help
+
+| Tool | What it is |
+| :-- | :-- |
+| **Squoosh** (web app) | Compare formats and quality side by side in your browser |
+| **ImageMagick** | A command-line tool for resizing and converting |
+| **cwebp / avifenc** | Command-line encoders for WebP and AVIF |
+| **Sharp** | A popular library for processing images in Node.js builds |
+| **SVGO** | A tool that makes SVG files smaller |
+| **Your image editor** | "Export for web" options in many editors |
+
+A few commands, for those who like the terminal:
+
+```bash title="terminal"
+# Resize a JPEG to 1200 pixels wide, with good quality
+magick input.jpg -resize 1200x -quality 80 harbor-1200.jpg
+
+# Convert to WebP
+cwebp -q 80 harbor-1200.jpg -o harbor-1200.webp
+
+# Convert to AVIF
+avifenc --min 20 --max 35 harbor-1200.jpg harbor-1200.avif
+```
+
+Exact options differ between versions, so check each tool's help.
+
+:::info Privacy: remove location data
+A photo taken on a phone may contain the exact coordinates of where it was taken. Publishing it without removing that data can reveal someone's home. Most export tools have a "remove metadata" option, and command-line tools such as `exiftool -all= photo.jpg` can strip it.
+:::
+
+## Formats and Page Speed
+
+Image weight directly affects speed, and speed affects real people.
+
+| For a visitor on... | A heavy image page means... |
+| :-- | :-- |
+| A slow mobile network | Long waiting, and a page that may never finish loading |
+| A limited data plan | Paying for every extra megabyte |
+| An older phone | Slower decoding and a laggy page |
+| A battery that is low | More energy used |
+
+Smaller images are one of the kindest things you can do for a global audience. A good target for most pages is to keep each content image **well under 200 KB**, and the whole page as light as you can.
+
+## Common Mistakes
+
+### Mistake 1: Using PNG for every photograph
+
+PNG files of photos can be several times larger than a good WebP or JPEG.
+
+### Mistake 2: Using JPEG for logos and text
+
+Lossy compression leaves fuzzy halos around sharp edges. Use SVG or PNG.
+
+### Mistake 3: Using a GIF for a long animation
+
+A short video is far lighter and sharper.
+
+### Mistake 4: Serving only AVIF or WebP with no fallback
+
+Some browsers may not display it. Use `` with a fallback.
+
+### Mistake 5: Re-saving a JPEG again and again
+
+Quality drops each time. Always export from the original.
+
+### Mistake 6: Keeping metadata
+
+It adds weight and can leak private information.
+
+### Mistake 7: Renaming a file to change its format
+
+Renaming `photo.png` to `photo.jpg` does not convert it. Use a proper export or conversion tool.
+
+### Mistake 8: Trusting an uploaded SVG
+
+Sanitize SVG files from visitors, or do not accept them.
+
+## Try It Yourself
+
+Here is a short project.
+
+1. Take one photo and save it as a JPEG at quality 90, 80, and 60. Compare their sizes and look at them side by side.
+2. Convert the same photo to WebP and AVIF with Squoosh or a command-line tool. Note each file size.
+3. Take a screenshot with text, and save it as PNG and as lossy JPEG. Zoom in on the text. Which looks cleaner?
+4. Make or download a simple logo as SVG. Show it at three different sizes in an HTML page. Does it stay sharp?
+5. Build a `` element that offers AVIF, WebP, and JPEG versions of your photo.
+6. Check a photo's metadata with a tool such as `exiftool`, then strip it.
+7. Write down which format you would choose for each image on a page of your own project, and why.
+
+
+
+
+## Quick Recap
+
+Click a question to check your answer.
+
+
+1. What is the difference between raster and vector images?
+
+Raster images are grids of pixels and get blurry when enlarged. Vector images are made of shapes and paths and stay sharp at any size.
+
+
+
+
+2. What does lossy compression do?
+
+It permanently discards some detail that the eye barely notices, so files become much smaller.
+
+
+
+
+3. Which format is best for logos and icons, and why?
+
+SVG, because it is a small vector format that scales to any size without losing sharpness.
+
+
+
+
+4. Why offer a JPEG fallback when using AVIF or WebP?
+
+Some older browsers do not support the newer formats. The `` element lets each browser choose the best version it can display.
+
+
+
+
+5. Why should you strip metadata from photos before publishing them?
+
+Metadata adds weight and can contain private details such as the exact location where a photo was taken.
+
+
+
+## Key Takeaways
+
+- Use **SVG** for logos, icons, and simple graphics, and **AVIF or WebP** for photos, with a **JPEG** fallback.
+- Use **PNG or lossless WebP** for screenshots and sharp text, and videos or animated WebP instead of GIF.
+- Resize before you compress, compress sensibly, and strip metadata.
+- Offer fallbacks with `` so every browser gets a format it understands.
+- Lighter images make your site faster, cheaper, and kinder to visitors everywhere.
+
+Now you know which files to make. Next, learn how to make images fit every screen in [Responsive Images](./responsive-images).
\ No newline at end of file
diff --git a/tutorials/html/05-images/img-element.mdx b/tutorials/html/05-images/img-element.mdx
index 7802ec308..e54fd158e 100644
--- a/tutorials/html/05-images/img-element.mdx
+++ b/tutorials/html/05-images/img-element.mdx
@@ -1,16 +1,419 @@
---
-id: img-element
-title: "The HTML Image Element: Inserting Images"
-sidebar_label: "Image Element ( )"
+id: html-img-element
+title: "The HTML img Element"
+sidebar_label: "The img Element"
sidebar_position: 2
slug: /html/images/img-element
-description: "Learn the fundamentals of the HTML img tag, its void element syntax, inline display behavior, and basic usage on web pages."
+description: "Learn how the HTML img element works. Understand how browsers load images, the core attributes, why images are inline, how to fix the small gap below an image, make images fit with CSS, handle broken images, and choose between img, picture, SVG, and CSS backgrounds on CodeHarborHub."
keywords:
+ - HTML img element
- HTML img tag
- - image element HTML
- - inserting web images
- - void elements img
+ - HTML image tag
+ - add image to HTML
+ - responsive image max-width
+ - object-fit CSS
+ - broken image HTML
+ - HTML decoding async
+ - fetchpriority HTML
+ - img vs background-image
+ - learn HTML images
- CodeHarborHub HTML
-authors: [ajay-dhangar]
-tags: [html, img-tag, markup, beginner]
----
\ No newline at end of file
+tags: [html, web-development, beginner, images, img, media, frontend]
+---
+
+export const sample = "data:image/svg+xml;utf8, ";
+
+Think about what happens when you put a photograph on a wall. You have to decide which photograph, where to hang it, how big it should be, and what to write on the little label next to it for people who cannot see it.
+
+The ` ` element is how you do all of that on a web page. It is one of the oldest and most used elements in HTML, and it looks simple. Behind that simplicity, there are details that decide whether your images load fast, fit the page, and work for everyone. This lesson shows you how ` ` works, from the inside out.
+
+
+
+
+## What You Will Learn
+
+- What the ` ` element is, and why it is a "replaced" element
+- What the browser does from the moment it finds an image
+- The core attributes and some useful extras
+- Why images are inline, and how to fix the small gap below them
+- How to make images fit any screen with CSS
+- What happens when an image fails, and how to prepare for it
+- When to use ` `, and when to use something else
+
+## The Basics
+
+An image needs a source and a description. Everything else is a bonus.
+
+
+
+
+```html title="index.html"
+
+```
+
+
+
+
+
+<>
+
+>
+
+
+
+
+
+The demo uses a small drawing built into the page, since there are no image files here. In your project, `src` would be a file path like the one in the code.
+
+## A "Replaced" Element
+
+Most HTML elements contain their own content: a paragraph holds text, a list holds items. An ` ` is different. It holds **nothing**. Its content comes from a **separate file** that the browser fetches and puts in its place.
+
+Because of this, ` ` is called a **replaced element**, and it is also a **void element**:
+
+- It has **no closing tag**. Write ` ` or ` `.
+- It has **no children**. You cannot put text or other elements inside it.
+- Its size comes from the file itself, unless you say otherwise.
+
+:::info In MDX, close it
+In plain HTML, ` ` is fine. In MDX and JSX, which this tutorial site uses, always write ` ` with the closing slash.
+:::
+
+## What the Browser Does With an Image
+
+Understanding this sequence explains many of the tips later in this section.
+
+1. **Reads the HTML** and finds the ` ` element.
+2. **Starts a request** for the file at `src`. This happens in parallel with other work, so the page keeps building.
+3. **Reserves space,** if it knows the size from `width` and `height`. If not, the space is empty until the file arrives.
+4. **Downloads the file** over the network. Big files take longer.
+5. **Decodes the image,** turning the compressed file into pixels.
+6. **Paints it** on the page. If the size was not reserved, the content below jumps to make room.
+
+This is why three habits matter so much: **small files** (steps 4 and 5), **`width` and `height`** (step 3), and **lazy loading** for images far down the page (step 2). You will learn each of them in this section.
+
+## The Core Attributes
+
+| Attribute | Purpose | Notes |
+| :-- | :-- | :-- |
+| `src` | The address of the image file | Required. See [Src and Alt](./src-and-alt) |
+| `alt` | A text alternative | Required. Use `alt=""` for decoration |
+| `width` | Width in pixels | Without `px`. Reserves space. See [Width and Height](./width-and-height) |
+| `height` | Height in pixels | Same as above |
+| `loading` | `eager` or `lazy` | See [Lazy Loading](./lazy-loading) |
+| `srcset` | A list of image files at different sizes | See [Srcset and Sizes](./srcset-and-sizes) |
+| `sizes` | How wide the image will be on screen | Works together with `srcset` |
+
+### A Few Extras Worth Knowing
+
+| Attribute | What it does | When to use it |
+| :-- | :-- | :-- |
+| `decoding="async"` | Lets the browser decode the image without blocking other work | Most content images |
+| `fetchpriority="high"` | Hints that this image is very important | The main image at the top of a page, often called the "hero" |
+| `crossorigin` | Controls how an image from another site is requested | When you draw it on a canvas, or use special security rules |
+| `referrerpolicy` | Controls what is sent about your page | For privacy, as in [Link Security](/tutorials/html/links-and-navigation/link-security) |
+| `title` | A tooltip | Use sparingly. Touch and keyboard users never see it |
+
+```html title="extras.html"
+
+
+
+
+
+```
+
+:::tip Do not use `title` instead of `alt`
+`alt` is for everyone who cannot see the image. `title` is only a tooltip that appears on mouse hover. They do different jobs, and `alt` is the one you must always write.
+:::
+
+## Images Are Inline
+
+By default, an ` ` behaves like a **letter in a sentence**, not like a paragraph. It sits on the same line as the text around it, and it lines up with the **baseline** of the text.
+
+
+
+
+```html title="inline.html"
+
+ A boat
+
+ can sit right inside a sentence.
+
+```
+
+
+
+
+
+<>
+
+ A boat{' '}
+ {' '}
+ can sit right inside a sentence.
+
+>
+
+
+
+
+
+That is perfect for small icons. For a large picture, you usually want it to stand alone as a block.
+
+### The Mysterious Gap
+
+If you put an image alone in a container, you may see a small **empty strip below it**. This is not a bug. The image sits on the text baseline, and the space under the baseline is reserved for letters like "g" and "y".
+
+There are two simple fixes.
+
+```css
+/* Fix 1: make the image a block */
+img {
+ display: block;
+}
+
+/* Fix 2: align it to the bottom of its line */
+img {
+ vertical-align: middle;
+}
+```
+
+Many developers add one of these to every project. A common choice is `display: block` for large images and `vertical-align: middle` for icons beside text.
+
+## Making Images Fit: A Few Lines of CSS
+
+An image keeps its natural size unless told otherwise. A photograph that is 3000 pixels wide will overflow a phone screen. This short rule makes images shrink to fit their container, and never grow beyond their real size.
+
+```css title="images.css"
+img {
+ max-width: 100%;
+ height: auto;
+}
+```
+
+- `max-width: 100%` stops the image from being wider than its container.
+- `height: auto` keeps the proportions, so the picture is not squashed.
+
+:::warning Keep `height: auto` with `width` and `height` attributes
+When you set `width` and `height` in HTML **and** use `max-width: 100%`, add `height: auto` too. Without it, the image may stay tall while its width shrinks, and look stretched.
+:::
+
+### Fitting an Image Into a Fixed Box
+
+Sometimes the box has a fixed shape, such as a square card. Use `object-fit` to decide how the picture fills it.
+
+| `object-fit` value | What happens |
+| :-- | :-- |
+| `fill` | Stretches to fill the box. Can distort the image |
+| `contain` | Shows the whole image inside the box, with empty space if needed |
+| `cover` | Fills the box and **crops** the extra. Best for cards and avatars |
+| `none` | Keeps the original size |
+| `scale-down` | Uses `none` or `contain`, whichever is smaller |
+
+```css title="card-image.css"
+.card img {
+ width: 100%;
+ height: 200px;
+ object-fit: cover;
+ object-position: center;
+}
+```
+
+### A Few More Handy Styles
+
+```css
+.avatar {
+ width: 64px;
+ height: 64px;
+ border-radius: 50%; /* a circle */
+ object-fit: cover;
+}
+
+.framed {
+ border: 4px solid #e2e8f0;
+ border-radius: 8px;
+ box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
+}
+```
+
+## When an Image Does Not Load
+
+Images fail more often than you might think: a typo in the path, a deleted file, a slow network, or a blocked request. The browser shows a **broken image icon**, and the `alt` text appears in its place.
+
+That is another reason `alt` matters: it is your fallback.
+
+```html
+
+
+```
+
+You can also react in JavaScript, for example to show a default picture.
+
+```html title="fallback.html"
+
+
+
+```
+
+The `{ once: true }` option makes sure the fallback runs only once, so a missing fallback file cannot cause an endless loop.
+
+### Quick Debugging Checklist
+
+1. **Check the path.** Is it relative to the right folder? See [Relative URLs](/tutorials/html/links-and-navigation/relative-urls).
+2. **Check the spelling and case.** `Photo.JPG` is not `photo.jpg` on most servers.
+3. **Check the file exists** and was uploaded.
+4. **Open the browser's developer tools.** The Network tab shows failed requests in red.
+5. **Check the file type.** A file that was renamed to `.jpg` but is really another format may fail to display.
+
+## Images That Are Links
+
+Wrap an ` ` in an `` to make it clickable. The `alt` text then becomes the link's name, so describe where the link goes.
+
+```html
+
+
+
+```
+
+## `img`, `picture`, SVG, or CSS Background?
+
+You have several ways to show an image. Each has a place.
+
+| Method | Best for | Notes |
+| :-- | :-- | :-- |
+| ` ` | Almost all **content** images | Accessible, searchable, easy to lazy-load |
+| `` | Different formats or crops for different screens | Contains an ` `. See [Picture Element](./picture-element) |
+| Inline `` | Icons and graphics you want to style or animate | Part of the page's HTML |
+| ` ` | A logo or illustration as a separate file | Cacheable and simple |
+| CSS `background-image` | **Decoration** that carries no meaning | Has no `alt`, so keep it for purely visual use |
+
+The rule of thumb: if the image **means something** to the reader, use ` `. If it is only decoration, a CSS background is fine.
+
+## Common Mistakes
+
+### Mistake 1: Forgetting `alt`
+
+Every ` ` needs an `alt`. Use an empty one for decoration, never leave it out.
+
+### Mistake 2: Using a huge file for a tiny space
+
+A 4000-pixel photo shown at 300 pixels wastes data and time. Resize it first.
+
+### Mistake 3: Squashing an image with the wrong `width` and `height`
+
+Set values that match the image's real proportions, and use `height: auto` in CSS.
+
+### Mistake 4: Putting content inside ` `
+
+It is a void element. Text placed between ` ` and `` is invalid.
+
+### Mistake 5: Using a CSS background for an important picture
+
+Without `alt`, a screen reader skips it, and search engines may ignore it.
+
+### Mistake 6: Not testing on a slow connection
+
+Use the developer tools to slow the network down, then see how your page loads.
+
+### Mistake 7: Hot-linking someone else's image
+
+It uses their bandwidth, it can break without warning, and it may break copyright rules. Use your own copy, and only if you have the right to.
+
+## Try It Yourself
+
+Here is a short project.
+
+1. Create a folder `images` and put two pictures in it: one photo and one small icon.
+2. Create `gallery.html` with an `` and add both images with `src`, `alt`, `width`, and `height`.
+3. Add `img { max-width: 100%; height: auto; }` in a `
+```
+
+
+
+
+## A Complete Gallery Example
+
+
+
+
+```html title="gallery.html"
+Harbor Gallery
+
+
+
+
+
+
+
+
+```
+
+
+
+
+| Moment | What downloads |
+| :-- | :-- |
+| Page opens | `harbor-1.jpg` (high priority) |
+| Visitor scrolls near picture 2 | `harbor-2.jpg` |
+| Visitor scrolls near picture 3 | `harbor-3.jpg` |
+| Visitor never scrolls to picture 4 | `harbor-4.jpg` is never downloaded |
+
+
+
+
+If the visitor leaves after the first screen, three images were never downloaded. That is data saved for them, and bandwidth saved for you.
+
+## Lazy Loading With `srcset` and ``
+
+Lazy loading works with everything you have learned. Put `loading` on the final ` `.
+
+```html title="lazy-picture.html"
+
+
+
+
+
+```
+
+`decoding="async"` is a good companion: it lets the browser decode the image off the main thread so scrolling stays smooth.
+
+## Lazy Loading Iframes
+
+`loading="lazy"` also works on `