Skip to content

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

Open
@tylersticka

Description

@tylersticka

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.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions