---
id: html-images
title: "HTML Images"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["img tag", "src attribute", "alt attribute", "HTML image size", "image as link", "image float"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.90
created_at: 2026-06-23
updated_at: 2026-06-23
review_reason: ""
merge_history: []
tags: ["html", "web", "frontend", "w3schools", "images", "media"]
raw_sources: ["https://www.w3schools.com/html/html_images.asp"]
applied_in: []
github_commit: ""
---
# [[HTML Images]]
## π― ν μ€ ν΅μ°° (One-line insight)
The HTML `` tag embeds an image via its required `src` (path) and `alt` (alternate text) attributes; images are linked into the page, not technically inserted. [S1]
## π§ ν΅μ¬ κ°λ
(Core concepts)
- **`
` tag** β embeds an image in a web page; it is empty (attributes only), has no closing tag, and images are linked to pages rather than inserted into them. [S1]
- **`src` attribute** β specifies the path to the image; the browser fetches it from a web server at load time. [S1]
- **`alt` attribute** β required; provides alternate text describing the image for when it cannot be viewed, and for screen readers. [S1]
- **Size** β set width/height via the `style` attribute or the `width`/`height` attributes (always in pixels); the source suggests using `style`. [S1]
- **Paths** β images can live in a sub-folder (include the folder in `src`) or on another server (use an absolute URL). [S1]
- **Animated GIFs, image links, floating** β HTML allows animated GIFs; nest `
` in `` for a link; use CSS `float` to float an image left/right of text. [S1]
## π§© μΆμΆλ ν¨ν΄ (Extracted patterns)
- **Embed pattern** β `
`. [S1]
- **Sizing pattern** β `style="width:500px;height:600px;"` or `width="500" height="600"`. [S1]
- **Sub-folder / cross-server pattern** β `src="/images/file.gif"` or `src="https://host/path.jpg"`. [S1]
- **Image-link pattern** β `
`. [S1]
- **Float pattern** β `style="float:right;"` / `style="float:left;"`. [S1]
## π μΈλΆ λ΄μ© (Details)
Images can improve the design and the appearance of a web page. [S1]
**HTML Images Syntax**
The HTML `
` tag is used to embed an image in a web page. Images are not technically inserted into a web page; images are linked to web pages. The `
` tag is empty, it contains attributes only, and does not have a closing tag. The two required attributes are `src` (the path to the image) and `alt` (an alternate text for the image). [S1]
```html
```
**The `src` Attribute**
When a web page loads, it is the browser, at that moment, that gets the image from a web server and inserts it into the page. [S1]
```html
```
**The `alt` Attribute**
The required `alt` attribute provides an alternate text for an image, if the user for some reason cannot view it. The value of the `alt` attribute should describe the image. A screen reader is a software program that reads the HTML code, and allows the user to "listen" to the content. [S1]
```html
```
**Image Size β Width and Height**
Using the `style` attribute: [S1]
```html
```
Using the `width` and `height` attributes (these always define the size in pixels): [S1]
```html
```
> **Note:** Always specify the width and height of an image. If width and height are not specified, the web page might flicker while the image loads. [S1]
**Width and Height, or Style?**
The `width`, `height`, and `style` attributes are all valid in HTML. However, the source suggests using the `style` attribute. [S1]
```html
```
**Images in Another Folder**
If you have your images in a sub-folder, you must include the folder name in the `src` attribute. [S1]
```html
```
**Images on Another Server/Website**
Some web sites point to an image on another server. To point to an image on another server, you must specify an absolute (full) URL in the `src` attribute. [S1]
```html
```
> **Note:** External images might be under copyright. If you do not get permission to use it, you may be in violation of copyright laws. In addition, you cannot control external images; they can suddenly be removed or changed. [S1]
**Animated Images**
HTML allows animated GIFs. [S1]
```html
```
**Image as a Link**
To use an image as a link, put the `
```
**Image Floating**
Use the CSS `float` property to let the image float to the right or to the left of a text. [S1]
```html
The image will float to the right of the text.
The image will float to the left of the text.