w3c / w3c/csswg-drafts

[css-inline] vertically align to middle of cap height

Open
#4,707 8 comments 53 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Closed Deferred css-inline-3
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

vertical-align: middle will align an element with the baseline of text minus half its x-height. This makes it a poor fit for glyph-sized elements like icons, which will always look a tad too low. Ideally we’d have a keyword (vertical-align: text-middle?) that would align with the middle of the cap height of the typeface instead…

The text "Favorite" with an adjacent heart icon and guidelines for type anatomy. The top version is middle-aligned with the text's x-height, while the bottom version is middle-aligned with the text's cap-height

In lieu of this property, I see two dominant techniques for accomplishing this:

  • The icon position is adjusted manually, using top: -1px or similar. This requires the icon to be inline-block, since other positioning techniques will conflict with the top value.
  • The icon and text must be wrapped in a container with display: flex; align-items: center or similar. But this prevents the icon from being used inline.

(I was encouraged to submit this issue after writing about the idea.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the issue description of vertical-align: middle, the proposed text-middle keyword, and the linked typeface-median article. Compare the two existing alignment techniques described there and determine the specification and design work needed for cap-height alignment; done means the CSS Working Group has a settled, implementable direction.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
design, frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.