Hình ảnh
Trang này cần trình duyệt gần đây (hỗ trợ SharedArrayBuffer). Vui lòng cập nhật Chrome, Edge, Firefox hoặc Safari lên phiên bản mới nhất.
English
Images
- Show a picture with the
<img>tag. <img>is a single tag — no closing tag, like<br>.- It needs two attributes:
src(where the picture is) andalt(a description).

English
<img src="/static/code/web-basics/cat.svg" alt="A cartoon cat">
English
Why alt text matters
altis text that describes the picture.- It shows if the image cannot load, and screen readers read it aloud.
- For an informative image, describe its meaning briefly. For a purely decorative image, use
alt=""so screen readers can skip it. Emptyaltand a missingaltare different.
English
Common mistakes
- Give the image
srcand analtappropriate to its purpose: meaningful text for information, or an empty value for decoration. <img>has no separate closing tag.
English
Now you try
- The picture lives at
/static/code/web-basics/cat.svg. - Show it, then add
alttext to an image.
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
Show the cat picture. Add an <img> with src="/static/code/web-basics/cat.svg".
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
This image has no description. Add an alt attribute that describes it, like alt="A cartoon cat".
Độ khó 1/5 · 100 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
The cat is a purely decorative flourish beside text that already gives the club information. Keep the image, but give it an empty alt value so screen readers can skip it.