liveBook · Manning

Img element

As explained in Web Design Playground

An HTML element that embeds an image in a web page.

An img element places an image on a web page. The image remains a separate file; the browser uses the element to find that file and display it where specified. section 6.1

Build the element from three useful attributes:

  • src points to the image file, using a filename, path, or full URL. section 6.1
  • alt supplies a short description for failed images and assistive technologies; use an empty value for decorative images. section 6.1
  • title optionally provides tooltip text when the pointer hovers over the image. section 6.1

A small image recipe

<img src="images/logo.png" alt="Example Company logo" title="Example Company"> Think of src as the image’s address and alt as a helpful spoken description. Use figure and figcaption when the image needs semantic framing, or place the img inside a link to make the picture clickable. section 6.1 section 6.34

An img element is inline, so it can flow inside a paragraph. CSS vertical-align can place it at the baseline, bottom, middle, or top of surrounding text. section 6.13

<img src="file" alt="description" title="tooltip">

Use this compact syntax as a checklist while adding an image. section 6.34

Try adding a logo to a page, then make a row of thumbnail images for a photo gallery. section 15.7

How Web Design Playground covers it

How deep it goes
Defines syntax, file paths, accessibility text, tooltips, inline flow, and alignment, while deferring image backgrounds to CSS.
Examples
Uses a company logo, gallery thumbnails, linked pictures, and a standard src-alt-title code pattern.
What it assumes
Assumes basic page text and HTML tags while teaching image files, paths, attributes, and accessibility from the beginning.
What you can do after
Build it from scratch by locating an image file, writing an img element, supplying alt text, and adjusting alignment.
How it connects
Connects images with HTML attributes, CSS vertical-align, figure, figcaption, links, and image formats.

Also explained in

Compare how 3 books explain img element →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground. The section links point to the parts of the book it draws on.