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.
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
- The markup. The table is
drawable. The<col>elements aren't drawn. They're read. - Find the column under the pointer from the boxes of the
<col>elements. - Draw the table, shade the other columns, add the light.
- 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.
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
- The markup. A
<dl>with one<div>for each term.<dt>and<dd>are bothdrawable. - A tap changes the angle the card is heading for.
- Draw one face of each card. Flat when it rests, in strips while it turns.
- The strips.
- 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
- The markup.
- Draw each item at a delay from its index.
- One item as a
drawable<li>, or as a row cut from the picture of the<ol>. - Switch between the three routes.
- 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.
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
- The markup. The scroll container is
drawable. The rows are added by script. - Draw the scroller, then its top band again with a shadow.
- 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.
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
- The markup.
- The path: a point and a direction for each position.
- Draw the line, then each item at its point.
- A sideways drag moves the list along the path.
- 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:
- An element that is read and not drawn. A
<col>has a box and no picture. The column light is placed fromcol.offsetLeftandcol.offsetWidth. - An element drawn whole, at a place the canvas chooses. The
<dt>,<dd>and<li>elements. The glossary draws a turning card in strips, because a 2D context has affine transforms only. - A part of an element's picture.
drawElementImage()with nine arguments draws a source rectangle. The list entrance uses it to draw one row of the<ol>with its marker. The sticky header uses it to draw the top band of the scroller again with a shadow. A source-rectangle draw moves the hit box of the whole element, so both demos finish with a full draw at zero alpha to put it back.
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
- Each demo starts when its section comes near the screen.
- 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.
- A
<col>has a box and no picture.offsetLeft,offsetWidthandgetBoundingClientRect()return the column.drawElementImage(col)throws "No cached paint record for element", with or without thedrawableattribute. - A background on a
<col>is in the picture of its table. Changing it raises apaintevent. <dt drawable>and<dd drawable>in one grid cell each have a full picture. The one drawn last takes the taps. A link in the<dd>is followed at the place the card was drawn.- An
outsidelist marker isn't in the picture of its<li>. The picture ends at the border box. A negative margin with the same padding doesn't help, because the marker is placed outside the border box. Aninsidemarker is in the picture. - The picture of the
<ol>has the outside markers. A source-rectangle draw of one row of it gives the item with its number. - A source-rectangle draw moves the hit box of the whole element. A full draw with
globalAlpha = 0afterwards puts it back. - The
drawableattribute can be moved between an<ol>and its items at run time. The new pictures are there on the nextpaintevent. reversedon the<ol>changes the markers in the pictures of the items and raises apaintevent.- A
drawablescroll container scrolls natively inside a canvas, by touch and by wheel, and every scroll step raises apaintevent.position: stickyheader cells stay at the top of its picture. A scroll container that isn'tdrawabledoesn't scroll from input on its drawn descendants: the page scrolls. - A canvas shadow applies to a source-rectangle draw.
shadowBlurandshadowOffsetYbefore the nine-argument call give the header a shadow in the shape of the band. - A
<thead drawable>nested in the drawable scroller also works while the canvas is fully on screen. An older finding on this site says a nested drawable element is recorded only where it is inside the window when it repaints, so this page uses the source rectangle by default. - An absolutely positioned
<li>keeps its list marker and its number. - Not verified: everything on a phone. In particular the momentum of a native scroll inside the canvas, whether the page scroll takes over at the ends of the table, the frame rate of the card turn (24 draws of one element for each frame), and a horizontal touch drag on the timeline next to a vertical page scroll.