]> git.ipfire.org Git - thirdparty/bootstrap.git/commit
Floating labels: place label before control for screen readers (#42539)
authorMark Otto <markd.otto@gmail.com>
Tue, 23 Jun 2026 17:27:23 +0000 (10:27 -0700)
committerGitHub <noreply@github.com>
Tue, 23 Jun 2026 17:27:23 +0000 (10:27 -0700)
commitd1c2750ce9fa60c1ae7913eb73aba2bbf8931b46
tree4237ed8c67aa14b700d059fe397fca2eea586052
parentf53f302c8c982e7964aee988f8ef4e0f6469691e
Floating labels: place label before control for screen readers (#42539)

Floating labels required the control to precede the `<label>` in the DOM
so the floating animation could use a sibling (`~`) selector. That order
made screen readers (e.g. NVDA) announce the label after the field's
value instead of before it.

Switch the SCSS to look forward with `:has()` so the `<label>` can come
first in the DOM while the CSS still reacts to the control's state
(focus, value, disabled, autofill). Reorder all examples, docs, and the
visual test to label-first markup to match.

Also give `.form-control-plaintext` its own copy of the control tokens so
its `var(--control-*)` references resolve, fixing phantom borders and
label misalignment.

Fixes #41362
js/tests/visual/floating-label.html
scss/forms/_floating-labels.scss
scss/forms/_form-control.scss
site/src/assets/examples/cheatsheet/index.astro
site/src/assets/examples/dialogs/index.astro
site/src/assets/examples/heroes/index.astro
site/src/assets/examples/sign-in/index.astro
site/src/content/docs/forms/floating-labels.mdx
site/src/content/docs/forms/validation.mdx