October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
accessibility

How to Add Images to HTML Tables

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Put an <img> element inside the <td> cell where the image should appear. Give it a working src and useful alt text. The image does not replace the table structure: keep the row, column, and header cells that explain what the data means.

Put the image inside the target table cell

An HTML table is built from rows and cells. Place the image markup between the opening and closing tags of the cell that should contain it:

<table>
  <caption>Available bicycle colors</caption>
  <thead>
    <tr>
      <th scope="col">Color</th>
      <th scope="col">Preview</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">Red</th>
      <td><img src="images/red-bike.jpg" alt="Red bicycle"></td>
    </tr>
  </tbody>
</table>

The <img> embeds the image; <table>, <tr>, <th> and <td> establish the table and its relationships. Putting an image in a data cell does not change those semantics. The example uses a row header for the color and a column header for the preview, so the image sits in the data cell at their intersection.

Keep the table meaningful

Use a table when the content has genuine row-and-column relationships, such as products and their attributes, or dates and corresponding measurements. Do not use table markup just to position an image beside text; ordinary layout elements and CSS are better suited to that job. Add a concise <caption> when it helps readers understand what the table contains.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Choose the right source and alternative text

Set a retrievable image URL

The src attribute can point to a relative path, such as images/red-bike.jpg, or an absolute URL. A relative path is resolved from the page’s location, so check where the page is served and where the image file is deployed. Filenames and paths can be case-sensitive on the server. The browser cannot show an image it cannot retrieve.

For example, if a page at /catalog/index.html uses src="images/red-bike.jpg", the browser looks for the image under that page’s relative images directory. If you move the page or the image, revisit the path. An absolute URL is useful when the image is hosted elsewhere, but that host must permit the browser to retrieve it.

Write alt text for the image’s purpose

For an informative image, use concise text that communicates the relevant content in context. In the bicycle example, alt="Red bicycle" identifies what the image adds to the row. Avoid using a filename or repeating nearby text when it would not help someone understand the cell.

If an image is purely decorative or repeats information already available in nearby text, use alt="". An empty value tells assistive technology that the image does not add information to convey. If the image is inside a link, describe the linked destination or action rather than merely listing its visual appearance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

The HTML image element uses the image supplied by src (and, where used, srcset) as embedded content; alt provides equivalent content for people who cannot process the image or have image loading disabled. Treating alternative text as part of the content—not an optional caption—is especially important in a data table, where a missing image should not leave the cell without useful meaning.

Control image size without breaking the table

Constrain images to the available cell width

A wide image can force a column to become wider than intended or overflow its cell. A fluid rule lets it shrink to the available width while preserving its aspect ratio:

img {
  max-width: 100%;
  height: auto;
}

Apply the rule only to images that should be fluid if other images on the page need different behavior. For example, use a class to target table previews:

.table-preview {
  max-width: 100%;
  height: auto;
}

Then add the class to the image:

<td><img class="table-preview" src="images/red-bike.jpg" alt="Red bicycle"></td>

Provide intrinsic dimensions when known

The width and height attributes communicate the image’s intrinsic dimensions to the browser and let it reserve the corresponding aspect ratio while the file loads:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<img src="images/red-bike.jpg" alt="Red bicycle" width="640" height="420">

Use the actual dimensions or their correct aspect ratio, rather than arbitrary values that distort the image. CSS can still constrain the rendered width; with height: auto, the browser keeps the image proportional.

Use responsive sources when one file is not ideal

When you have differently sized versions of an image, srcset and sizes can give the browser information to choose a suitable source for the display size and device. For example:

<img
  src="images/red-bike-640.jpg"
  srcset="images/red-bike-320.jpg 320w, images/red-bike-640.jpg 640w, images/red-bike-1200.jpg 1200w"
  sizes="(max-width: 600px) 50vw, 240px"
  width="640"
  height="420"
  alt="Red bicycle"
>

The width descriptors identify the pixel widths of the candidate files; sizes describes the expected rendered width under the stated condition. Keep the fallback src valid and make sure each candidate file exists. Responsive sources are useful when the same table may be shown at substantially different sizes; for a small, fixed preview, one appropriately sized source may be simpler.

Check the implementation when something looks wrong

Common HTML table image problems and fixes
Symptom What to check Fix
Image appears outside the intended cell Whether the <img> is actually between that cell’s opening and closing <td> tags; whether the row and cell tags are closed in the right order. Move the image into the target cell and correct the table nesting. A cell with no closing tag can cause following content to be parsed in an unexpected place.
Broken image or empty cell The exact src, file location, spelling, capitalization, and whether the server returns the image. Correct the URL or deploy the file at that location. Inspect the browser’s network response to distinguish a wrong path from a retrieval failure.
Image exceeds the cell The image’s rendered width and the available table or cell width. Constrain the image with max-width: 100%; height: auto; and check whether the table itself has enough available width.
Assistive technology gets little useful information Whether the image adds meaning, whether the alt describes that meaning in context, and whether nearby text already conveys it. Write concise informative alt text, or use alt="" if the image is decorative or redundant.

Debug the URL before changing the layout

If an image fails to load, first try its URL directly in the browser and inspect the network response. Confirm the exact filename and capitalization, then verify that the file is present in the deployed location. CSS cannot repair a missing or inaccessible image. If the URL works but the image is too large, then adjust its CSS sizing and inspect the table’s available width.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check markup nesting when placement is wrong

In a row, each cell belongs between that row’s opening and closing tags. Make sure the image is nested inside the correct cell, and close every row and cell. If placement changes after adding an image, inspect the HTML around that row for a missing or misplaced closing tag before adding positioning rules.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Make and inspect a table screenshot

Adding an image to a table is ordinary HTML authoring; you do not need a special product to do it. If you want to inspect the rendered result for visual issues, capture the page in a browser or use a screenshot service. A screenshot can help spot clipping or an unexpected column width, but it does not replace checking the markup, the image URL, and the alternative text.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. It can capture a page as PNG, JPEG, WebP, or PDF. Its clean-shot steps can accept cookie or consent banners and remove known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers indicate the page verdict and billing status. AI agents can use its MCP tools to take screenshots, get page information, and capture PDFs.

For a quick visual check of a publicly reachable page containing your table, one GET request can save a WebP screenshot:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/table-page -o table.webp

See the ScreenshotNeo API documentation for request options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed; an MCP server lets AI agents take screenshots; and 1,000 screenshots a month are free with no card, with paid plans starting at $5 for 3,000. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month with no card.

Use image files you have permission to publish

Before deploying an image, make sure you have permission to publish it. A technically valid URL and an accessible file do not establish that you have the right to use the image. This matters whether the file is stored with your site or retrieved from another host.

Frequently Asked Questions

Does the image have to be in the same folder as the HTML file?

No. Its src can use a relative path to another deployed location or an absolute URL, provided the browser can retrieve the file.

Can a table cell contain both text and an image?

Yes. A <td> can contain both, as long as the content belongs to that cell and the row-and-column structure remains meaningful.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do I need a special tool to put an image in a table?

No. The markup uses standard HTML elements: place an <img> inside the appropriate table cell.

Quick Recap

SaleBestseller No. 1
Web Design with HTML, CSS, JavaScript and jQuery Set
Web Design with HTML, CSS, JavaScript and jQuery Set
Brand: Wiley; Set of 2 Volumes
$35.05
SaleBestseller No. 2
HTML and CSS: Design and Build Websites
HTML and CSS: Design and Build Websites
HTML CSS Design and Build Web Sites; Comes with secure packaging; It can be a gift option
$14.18

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.