THE GITHTML FIELD GUIDE
Why a canvas drawing vanishes after saving HTML
A canvas element's drawn pixels are not ordinary child markup, so saving its HTML does not necessarily preserve the drawing. Export an image or another suitable static representation and include a textual explanation of the important information. The presence of a canvas tag alone is not evidence that a chart survived the export.
Identify the specific failure
The drawing may have been produced from data only available in memory. Reopening a canvas without the rendering code and inputs leaves an empty drawing surface. A copied width and height preserve dimensions, not the visual content.
Make a narrow correction
Obtain an authorized snapshot at the intended state and retain the values needed to interpret it. If a chart supports a decision, include relevant data or a concise summary alongside the image. Avoid an unexplained bitmap that hides units and observation time.
- Check whether the export contains actual image data or only a canvas element.
- Capture the intended state with its units, legend, and observation time.
- Provide an explanatory text or table for the conclusion conveyed by the drawing.
<figure><img src="chart-snapshot.png" alt="Error count declines from 12 to 3"><figcaption>Snapshot of the approved observation period.</figcaption></figure>Capture the intended chart state and its interpretation
Consider a canvas chart showing a selected week and two enabled data series. Its pixels were drawn after the application fetched values and applied the current filters. The canvas tag in saved HTML does not contain that drawn bitmap. Before producing a static image, record the selected week, series names, units, and any excluded values. A visually similar chart drawn from the default state can tell a different story, so compare the snapshot with the approved live state rather than merely confirming that an image file was created.
Include the information a reader needs to interpret the picture: axis labels, legend, observation time, and a concise account of the relevant relationship. For a small dataset, an accompanying table can make exact values available without forcing readers to estimate them from pixels. Use an authorized export mechanism and do not bypass browser restrictions to extract material the page is not permitted to expose. If an export fails, the publisher can supply a reviewed image or data summary through an appropriate workflow.
Check the static asset's smallest meaningful text at the size it will actually occupy in the document. Increasing the displayed width of a low-resolution capture does not restore missing detail. Likewise, CSS resizing that changes the aspect ratio can distort a chart's geometry. Keep a proportional presentation and provide a focused detail or text explanation where necessary. Fallback content inside a canvas can be useful, but it should not be the only place where an essential conclusion is explained. Ordinary adjacent HTML makes the interpretation available regardless of whether the drawing, its script, or its replacement image renders.
Verify the repaired artifact
Reopen the copy without the original application and compare labels, values, and legends against the captured state.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.