Tables and blocks: caption, tfoot, time, data, address and marquee
Five ideas from the element catalogue about elements that carry a fact: the caption and the footer of a table, the machine form of a date or a number, a postal address, and a line of links that scrolls. In each demo the element stays in the document with its own text, and the canvas draws it somewhere else or draws around it.
Caption as a rubber stamp
An invoice whose <caption> says that it's paid. Press the button: the caption leaves its place above the rows and comes down across them, turned, larger and red, inside a frame.
A <caption> isn't drawable by itself. It's a box inside the picture of the table, as wide as the table, so the stamp is a draw of the table clipped to the box of the words. A ctx.filter on that draw turns them red.
Show the code
- A table with a caption. The table is the
drawableelement. - Draw the rows, then the caption's words turned and enlarged.
- Place the table, and draw one box of it somewhere else.
- Styles.
Footer totals that count up
A basket. Change a quantity with the buttons or type one. The total in the <tfoot> counts to its new value over 0.6 seconds, and while it counts the footer row is drawn lifted and larger, with two faint copies of itself trailing behind.
The number that counts is the text of the footer cell, written on every frame, so a screen reader and a copy of the table get the same value as the eye. The lift and the copies are three clipped draws of the table at the box of its <tfoot>.
Show the code
- The table, with real inputs and buttons in its cells.
- Write the cell on each frame, and draw the footer row as its own piece.
Machine values next to shown values
A notice with two <time> and two <data> elements, which have a dotted line under them. Hold the button, or the M key: the datetime or value attribute of each is drawn in a tag above it.
The attributes aren't in the picture of the paragraph. The canvas reads them from the elements and draws them as its own text, placed from each element's first client rectangle.
Show the code
- The paragraph.
- Draw each attribute in a tag above its element.
Address on an envelope
Type a name, a street and a town. The script writes them into an <address> element, and the canvas draws that element on an envelope. Press the button: the flap closes, the envelope leaves and an empty one arrives.
The address on the envelope is the element, not a copy: each key press in a field changes its text, the browser raises paint, and the envelope is drawn again. The form is drawn flat under the envelope, so its fields take input where they are seen.
Show the code
- An
<address>and a form, bothdrawable. - Draw the envelope, the address on it, the flap and the form.
Stock ticker with real links
A <marquee> with six links in it, drawn as a board of lit dots with a reflection under it. The marquee scrolls by itself. Tap a symbol while it moves.
There's no frame loop in this demo. Each step of the marquee raises a paint event that names it, and the board is drawn then. The links are hit-tested by the browser at the place where they are at that moment.
Show the code
- A
drawablemarquee of links. - Draw the board on each paint event the marquee raises.
- A paint handler with no frame loop.
How it works
- One drawable block per effect. A caption, a footer and a
<time>aren'tdrawable: they're parts of the picture of the table or paragraph around them. A part is drawn by clipping a draw of the whole block to the part's box (offsetLeft,offsetTop,offsetWidth,offsetHeight). - Where input goes. A block that is drawn in pieces is placed once more at the end with a draw that is clipped away completely. That draw puts no pixels on the canvas and sets the hit region.
- Frames. The first four demos ask for frames only while something moves. The ticker never asks: the marquee's own repaints are its clock.
Show the code
- Place a block, and draw one piece of it.
- Each demo starts when its section comes near the screen.
- The paint handler of the first four canvases.
- After a lost context the elements are shown as plain HTML.
Live checks
The checks wait for a tap. Each builds its own small canvas in a corner of the window, and none of them touches the demos above.
Findings
Measured in headless Chromium 157 on 2026-11-21. Not yet run on a phone.
- A caption and a table footer can be moved as pictures by clipping. Neither is
drawableby itself. In a table withposition: relativethe caption was at 0, 0 and 200 by 24 px, and thetfootat 0, 76 and 200 by 26 px. A draw of the table clipped to one of those boxes moves that part alone. Withcaption-side: bottomthe caption's box is under the footer (78 against 52). - A caption's box is as wide as the table. The words in it were 33 px of 200. The stamp uses the box of a
<span>inside the caption. ctx.filterrecolours a clipped piece.brightness(0) invert(0.45) sepia(1) saturate(30) hue-rotate(-40deg)on the draw of the caption gave red letters, with no readback and no second canvas.- Text written into a cell on every frame keeps up. Five changes of a
tfootcell 100 ms apart raised five paint events that name the table. In the demo the cell's text is the count, so the canvas has nothing to draw over it. datetimeandvaluearen't in the picture. A block was 220 by 24 px with and without them. They're read fromtime.dateTimeanddata.valueand drawn as canvas text at the element's first client rectangle.- A drawable
<marquee>is a clock. It raised 60 paint events in one second while it scrolled and none afterstop(). The ticker has norequestAnimationFrame()call and no timer. - Links in a scrolling marquee are hit-tested where they are.
elementFromPoint()found a moving link in 10 of 10 samples while its left edge went from 113 to -22 px. The board is drawn with two blurred copies, a reflection and a dot mask, and the last draw of the marquee is a clipped-away one at its upright place. - An
<address>and its form can share a canvas. A tap on the drawn Town field focused that field, and typed text reached the address on the envelope on the next paint. - Not verified: everything on a phone. The speed of the ticker's three filtered draws at 60 paint events a second, the on-screen keyboard over the envelope form, and holding a finger on the button of the third demo without a long-press menu.