Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Issues
  • #37433
Closed
Open
Issue created Nov 05, 2022 by Patrick H. Lauke@patrickhlaukeContributor2 of 2 checklist items completed2/2 checklist items

v6: Make sure `<button>` and `<a>` links have same vertical text alignment

Prerequisites

  • I have searched for duplicate or closed feature requests
  • I have read the contributing guidelines

Proposal

split out from https://github.com/twbs/bootstrap/pull/37432#issuecomment-1304469946

for v6, it would be good to revisit styles for <button>, so authors can use the correct <button> element without incurring visual penalties/having to do extra work to make it look seamless when placed next to static text or <a> links.

Motivation and context

Use of <a href="#" role="button"> for pseudo-buttons/toggles is ... "ok", but the recommended/ideal scenario is using actual <button> elements. Beyond idealistic "it's the correct semantic element to use", there are differences in how <a> and <button> operate:

  • links still give you context menus in browsers with "Open in new tab..." etc, which make no sense for these types of controls
  • <button> can be activated using Space and Enter (and this is what screen readers will announce as a hint in most cases), while <a> only reacts to Enter; when a link "pretends" to be a button with role="button", it can happen that AT users will try to activate it using Space but that will have no effect (and visually, that will just scroll the current page in the browser)

with our current v5 styles though, it's sometimes not easy to use appropriate <button> elements, as the styling is subtly different when dropped in with regular text/links...the vertical alignment of button content is slightly off

taking https://getbootstrap.com/docs/5.2/components/navbar/#supported-content as an example, changing the control to <button class="btn btn-link nav-link dropdown-toggle">...</button> gets us close, but the vertical text alignment is off

screenshot of the navbar, with the dropdown using a button, with the text in the button not aligning with the other links

that is, i think, one of the main reasons why for some components/patterns, authors still use an <a href="..." role="button"> at the moment...because the alternative just doesn't work out of the box.

Assignee
Assign to
Time tracking