Lists and tables: col, dl, ol and thead drawn by a canvas

Five canvases. Each holds an ordinary table or list and draws it in a way CSS does not: a light that follows the pointer along a <col>, a <dl> as cards that turn over, an <ol> whose items enter one after another, a sticky <thead> that casts a shadow on the rows under it, and an <ol> laid along a curve. Tap, drag and scroll inside them. The buttons, checkboxes and numbers are the real elements.

Column highlight from <col>

Move a pointer or a finger sideways across the table, or tap a column. The canvas reads the box of the <col> under the pointer and draws a light over that column. "Flat fill" sets a background on the <col> instead, which is what CSS can do alone.

Loaves sold in one week (sample data)
Sourdough4238514766
Baguette80747790112
Rye1821161925
Focaccia129142231
Brioche2724302644
Ciabatta3329353140
Bagel5861497083

A <col> has no picture: drawElementImage(col) throws. It does have a box. offsetLeft, offsetWidth and getBoundingClientRect() give the column, so the canvas knows where to put the light without measuring any cell.

Show the code
  1. The markup. The table is drawable. The <col> elements aren't drawn. They're read.
  2. Find the column under the pointer from the boxes of the <col> elements.
  3. Draw the table, shade the other columns, add the light.
  4. Styles.

Glossary cards from a <dl>

Six terms. Each <dt> is the front of a card and its <dd> is the back. Tap a card to turn it over. Tap the back to turn it again. With a keyboard, Tab to a term and press Enter.

The attribute on a <canvas> that lets it draw its own descendants. They are laid out and take input, and are not painted on the page.
The attribute on a descendant that gives it a picture of its own. An element without it cannot be passed to a draw call.
Fired on the canvas when the rendering of a drawable descendant has changed. The handler draws the new pictures.
Draws the picture of an element into a 2D canvas, and moves the element's hit box to where it was drawn.
Where the browser thinks an element is for taps, hover and focus. A link drawn here still works: go to Findings.
A snapshot from captureElementImage(). It keeps the look the element had, and can be drawn after the element has changed.

A 2D context has no perspective. During a turn the card is drawn in 24 vertical strips, each with its own scale, and the last strip leaves the hit box wrong. When the turn ends the card is drawn once, flat, and the other face is taken out of hit testing.

Show the code
  1. The markup. A <dl> with one <div> for each term. <dt> and <dd> are both drawable.
  2. A tap changes the angle the card is heading for.
  3. Draw one face of each card. Flat when it rests, in strips while it turns.
  4. The strips.
  5. Styles.

Staggered list entrance

An ordered list of seven steps. Each <li> is drawn 90 ms after the one before it. The checkboxes work while the items move. The first menu chooses where the numbers come from, and one of the three choices loses them.

The picture of an <li> ends at its border box. A marker with list-style-position: outside is outside that box, so it isn't in the picture. Two routes keep the numbers: list-style-position: inside, or drawing rows of the whole <ol> with a source rectangle.

Show the code
  1. The markup.
  2. Draw each item at a delay from its index.
  3. One item as a drawable <li>, or as a row cut from the picture of the <ol>.
  4. Switch between the three routes.
  5. Styles.

Sticky header that casts a shadow

A table of 40 rows in a scroll container that is drawn by the canvas. Scroll it with a finger, a wheel or the keyboard. The browser does the scrolling and keeps the header at the top. The canvas draws the header again on top, a little larger, with a shadow that deepens over the first 140 px of scrolling.

#PathmsKeep

A drawable scroll container scrolls natively inside the canvas, by touch and by wheel, and each scroll step raises a paint event. So the shadow needs no frame loop and no scroll listener: the paint handler reads scrollTop.

Show the code
  1. The markup. The scroll container is drawable. The rows are added by script.
  2. Draw the scroller, then its top band again with a shadow.
  3. Styles. The header cells are position: sticky.

Timeline from an ordered list

Eight dated items in an <ol>, drawn along an arch. Drag sideways, tap an item, or use the buttons. The number on each card is the list marker of its <li>. Tick "reversed" and the browser renumbers them.

  1. The img elementNCSA Mosaic shows pictures inside a page.
  2. JavaScriptWritten at Netscape for Navigator 2.
  3. CSS level 1Becomes a W3C Recommendation.
  4. The canvas elementApple adds it to WebKit.
  5. WebGL 1.0Khronos publishes the specification.
  6. HTML5Becomes a W3C Recommendation.
  7. OffscreenCanvasShips in Chrome 69.
  8. WebGPUShips in Chrome 113.

Every <li> is laid out at the same place and drawn at a point on the path, rotated to the path's direction. The markers are inside, so each picture carries its number. Changing reversed raises a paint event and the new numbers are drawn.

Show the code
  1. The markup.
  2. The path: a point and a direction for each position.
  3. Draw the line, then each item at its point.
  4. A sideways drag moves the list along the path.
  5. Styles.

How it works

Each canvas has content="drawable" and holds a real table or list. The parts that are drawn on their own carry the drawable attribute. A paint handler draws them with drawElementImage(), which also moves each element's hit box to where it was drawn. The five demos use the elements in three ways:

No demo runs a frame loop while it rests. A demo's script is loaded when its section comes near the screen, and it asks for frames only while something is moving.

Show the code
  1. Each demo starts when its section comes near the screen.
  2. The paint loop and the draw helpers (mount(), put(), hitOnly(), park()).

Live checks

The checks wait for a tap. Each one builds its own small canvas in a corner of the window and reads pixels from a copy of it. None of them touches the demos above.

Findings

Measured in headless Chromium 157 on 2026-11-21, at 412 px wide with a mouse, a keyboard and emulated touch.