We wrote the same number, 3, to addresses 00 and 01. On switching between them, the value was the same but the write bits differed. Where did those two states stay with no JavaScript or storage API? The browser kept the selected radios. CSS read those selections to display the current value and reveal the next Write label.
After writing to both cells, we changed the radio groups and the Write rule one at a time to test that explanation. Here, “memory” means state held while the same form remains open.
01. Write the same value to both cells and read back different states
After Reset, both cells show 0 / 0. The left number is the value. The right is a one-bit marker that distinguishes writes in this demo. Leaving one cell untouched is a useful baseline. A stronger check is whether the states stay separate after writing to both.
In a 1,363 CSS px cloud Chrome window, we pressed Reset, selected 01, clicked Write twice, selected 00, and clicked Write once. Then we revisited 01 and 00 in that order.
| Address revisited | Visible value / write bit | Checked cell radios |
|---|---|---|
| 01 | 3 / 0 |
s00a, s01b
|
| 00 | 3 / 1 |
s00a, s01b
|
Both values are 3, but the write bits differ. Switching addresses left both cell radios checked. Only the read address changed. Which selections does the browser hold, and how does CSS use them?
Figure 1. Baseline: write 3 to 00, read 0 at 01, then return to 00 and read 3 again.
02. The address selects what to read; Write changes only that cell
There are three radio groups. addr selects which cell to read; cell00 and cell01 retain the state of their respective cells. A selected radio represents a state instead of assigning a number to a variable. For example, the selected radio s00a represents value 3 and write bit 1.
| Role | DOM evidence | After selecting 01 |
|---|---|---|
| Read address | input[name="addr"]:checked |
Changes from a00 to a01
|
| State of 00 | input[name="cell00"]:checked |
Unchanged |
| State of 01 | input[name="cell01"]:checked |
Unchanged |
| Visible readout | The .read matching the selected address and cell state |
Shows the value and bit from 01 |
The HTML checked attribute defines the default selection; CSS :checked matches the current state. Inspect the currently checked input after clicking, not the literal checked attributes in the source. WHATWG: radio groups and checkedness
Follow one Write at address 00
First, when address 00 and its initial state s00z are selected, form:has(#a00:checked):has(#s00z:checked) matches and reveals the label with for="s00a". Second, activating the label in the tested Chrome instance selects its associated radio, s00a, and unchecks s00z in the same group. Third, the new selection makes CSS show 3 / 1 and expose the label for s00b as the next Write.
| Selected radio | Visible value / write bit | Target of Write |
|---|---|---|
s00z |
0 / 0 | s00a |
s00a |
3 / 1 | s00b |
s00b |
3 / 0 | s00a |
The last two rows explain repeated writes: the result stays at 3 while a different radio is selected. The bit returns to 0 after two clicks, so it cannot tell you a total write count or serve as an audit trail. WHATWG: labels and activation · W3C: the relational :has() selector
Figure 2. Writing 3 twice to 00 keeps the value at 3 while the write bit steps through 0 → 1 → 0.
03. Merging the groups breaks reads; targeting the same state stops writes from advancing
If radio groups hold the states separately, merging their names should remove 00’s initial selection. If the groups stay separate but the second Write points to the already selected radio, the readout should remain visible while the bit stops changing. We changed one condition per copy and tested both in 360 and 320 CSS px Chrome frames.
| Changed condition | Observed result |
|---|---|
| Baseline: one group name per cell | Repeated writes at 00 went from 3 / 1 to 3 / 0; 01 stayed at 0 / 0 |
Change only the three 01 group names to cell00
|
Reset at 00 showed neither a readout nor a Write control. Writing at 01 showed 3 / 1; switching back to 00 still showed neither |
Route only the second Write at 00 to the already selected s00a
|
The second click left s00a selected and the readout at 3 / 1; the write bit did not change |
After reset in the shared-group variant, only s01z was checked. Both cells can no longer have a selected state at once, so the readout rule for 00 matches nothing. The second variant kept the cells independent but did not transition to a different radio. These controls fail for different reasons, even though the unchanged markup can make the interaction look similar.
The first variant has no selected state to read; the second has a valid state but does not advance. A visible 3 tells you little on its own. Check the selected radio as well as the readout.
04. Keep it as a demo; use application state when the requirements grow
With three states per cell, the example has 2 × 3 × 3 = 18 possible combinations including the selected address. The observed click sequences do not cover all 18 browser states. Adding more cells and values expands the markup and the mapping for the next available selection; an explicit data model is more maintainable when the app needs arbitrary input.
Reset restores the form defaults. Any values a browser restores on history traversal or reopening are not a persistence guarantee made by this code. This implementation has no recoverable application storage. WHATWG: resetting a form
We also tried one keyboard path at 360 CSS px: from a focused Reset, Shift+Tab reached address 00, ArrowRight selected 01, and Tab returned to Reset, skipping Write. This path did not provide keyboard access to writing. It was not a comprehensive keyboard or screen-reader audit.
Back to the opening question: the value survived an address switch because the browser retained the selected radio in each group. That is enough to demonstrate a small state transition. For a product, choose the implementation based on what has to work.
- For keyboard writes, start with a named button and a usable focus order. Test the full write interaction with the keyboard and assistive technology.
- For reloads, return visits or multiple devices, define how far the data has to persist. Choose browser or server storage that matches that scope.
- For who changed what and when, keep a separate change history. An alternating bit cannot supply one.
When you run the file below, watch the checked radios as well as the numbers. That gives you a concrete line between what the form does and what the application must handle.
Appendix: runnable HTML and controls
Save the code as memory-map.html and open it in Chrome. Follow the baseline table first. We ran these steps at 1,363 and 360 CSS px in cloud Chrome. In a separate 360 CSS px check, writing only to 01 gave 3 / 1 at 01 and 0 / 0 at 00. These results and the 320 CSS px controls do not establish physical-device or cross-browser coverage.
Make one fresh copy per control. In the first, replace only the three name="cell01" attributes with name="cell00". In the second, find the rule that matches both #a00:checked and #s00a:checked, then change only its [for="s00b"] target to [for="s00a"].
| Action | Observed address | Observed value / write bit |
|---|---|---|
| Reset | 00 | 0 / 0 |
| Write 3 | 00 | 3 / 1 |
| Select 01 | 01 | 0 / 0 |
| Select 00 | 00 | 3 / 1 |
| Write 3 again | 00 | 3 / 0 |
| Reset | 00 | 0 / 0 |
<!doctype html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Two-cell form memory</title>
<style>
.write, .read { display: none }
form:has(#a00:checked):has(#s00z:checked) [for="s00a"],
form:has(#a01:checked):has(#s01z:checked) [for="s01a"],
form:has(#a00:checked):has(#s00a:checked) [for="s00b"],
form:has(#a01:checked):has(#s01a:checked) [for="s01b"],
form:has(#a00:checked):has(#s00b:checked) [for="s00a"],
form:has(#a01:checked):has(#s01b:checked) [for="s01a"],
form:has(#a00:checked):has(#s00z:checked) .read00z,
form:has(#a01:checked):has(#s01z:checked) .read01z,
form:has(#a00:checked):has(#s00a:checked) .read00a,
form:has(#a01:checked):has(#s01a:checked) .read01a,
form:has(#a00:checked):has(#s00b:checked) .read00b,
form:has(#a01:checked):has(#s01b:checked) .read01b { display:inline }
.write { border:1px solid; padding:.35em .7em; cursor:pointer }
</style>
<form>
<fieldset><legend>Address</legend>
<label><input id="a00" name="addr" type="radio" checked>00</label>
<label><input id="a01" name="addr" type="radio">01</label>
</fieldset>
<div hidden>
<input id="s00z" name="cell00" type="radio" checked>
<input id="s00a" name="cell00" type="radio">
<input id="s00b" name="cell00" type="radio">
<input id="s01z" name="cell01" type="radio" checked>
<input id="s01a" name="cell01" type="radio">
<input id="s01b" name="cell01" type="radio">
</div>
<p>Value / write bit:
<span class="read read00z read01z">0 / 0</span>
<span class="read read00a read01a">3 / 1</span>
<span class="read read00b read01b">3 / 0</span>
</p>
<p>
<label class="write" for="s00a">Write 3</label>
<label class="write" for="s00b">Write 3</label>
<label class="write" for="s01a">Write 3</label>
<label class="write" for="s01b">Write 3</label>
<button type="reset">Reset</button>
</p>
</form>


Top comments (0)