Is there a canonical rule how to vertically center text in a box? Or, in other words, how to align a box around text? I could imagine three options based on typographic metrics (see my non-exact illustration):

  • Align on the middle of x-height
  • Align on middle of cap height ("mean line")
  • Align on middle of cap + descender height

enter image description here

I'm mostly a programmer, but I often have to do this, and would like to know if there is a common shared rule, or if you designers do just as you see fit. I would prefer links to graphic design books instead of personal opinions.

  • 2
    The relation between capital and lowercase heights is an important factor here. The answer may very well be "it depends" – on the font.
    – Jongware
    Commented Jul 6, 2016 at 10:39
  • somebody just asked a similar question today, but this one is more complete and better written
    – Luciano
    Commented Jul 6, 2016 at 11:34
  • 2
    This has been asked and there is no really good solution for it, even individual words tend to want to center in different places in many fonts. There is no entirely correct mathematical solution.
    – joojaa
    Commented Jul 6, 2016 at 12:24

3 Answers 3


Good question!

I really like, and agree with, the answers given so far. My answer focuses more on pragmatic technique rather than scientific or mathematical reasoning. :D

With that said, my preference is to use the baseline and x-height (see Type Terms section below) as the starting point for my box’s top and bottom lines respectively. Hopefully this GIF helps to explain:

enter image description here

Once I get the path to line up with the baseline or x-height, I then use SHIFT + UP or DOWN arrow keys to create visual padding (by default, in Photoshop, each increment is 10px, so in the above example, I added 40px padding on top and bottom).

In this example you can see what the align tool does if I were to take the same box/text and do an “Align Vertical Centers” (red text is the result of using alignment tool):

enter image description here

As you can see, it’s pretty close (2px difference).

To summarize/conclude:

Techniques I use:

  1. Align box’s top/bottom paths to the x-height/baseline respectively (and then SHIFT arrow keys outward for visual padding.
  2. Similarly, sometimes I’ll arrow key the text up and down until it’s baseline and x-height meet the box’s bottom and top borders; from there, I’ll count the pixels and then evenly spread the remainder between the two directions as I center the text.
  3. Select both the box and the text, then do a “Align Vertical Centers” and “Align Horizontal Centers”.
  4. Lastly, there are times when I eyeball the placement. Usually, I go upwards vs. downwards to avoid visual ”sag” (this relates to picture framing, see Picture Framing section below); this is especially true if the font size is an odd number height and a 1px diff is the remainder … I will shift the text 1px (or more) upwards instead of downwards.

Picture framing

The most common used matting has an equal margin all the way around. On artwork with the visual center lower than actual center,.[8] Bottom weighting, or off-sets are used frequently in matting. The bottom margin are made larger than the side and top margins. When looking at an image, the eyes tend to center higher up than the physical center of the image. By creating a larger bottom margin and off-setting the mat you draw the eye to physical center of the image. Top Center is a subset of bottom weighting where the top and side margins are equal, which creates a visually pleasing effect. This is particularly true in mats where the borders are not equal, such as an 11x14 with an 8x10 opening.
WikiPedia: Mat (picture framing)

… and here:

Mats are 'weighted' on the bottom because our eye/brain feels the pull of gravity. If a mat is the same width all around, our brain will 'register' the bottom as slightly narrower (the image is not visually centered in the mat)
WetCanvas > The Learning Center > Studio Tips and Framing > Framing Discussions Reload this Page Weighting the bottom of the mat

Type Terms

enter image description here


Here’s a GIF comparing cap height, descender, ascender with all lower case with no descender/ascenders:

enter image description here

I think both versions line up pretty nicely within the box.


Visual weight is so dynamic that it really cannot be dictated by x-height, cap height, etc...

Certain elements in your design may pull the eye in one direction over the other despite mathematically being "center", from its left to right side in comparison to the canvas, for instance.

The "visual center" is where all of the elements weights are balanced visually despite not being in the exact center.

You may want to try experimenting with this tool: http://javier.xyz/visual-center/

  • Welcome to Graphic Design! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Luciano
    Commented Jul 6, 2016 at 15:24
  • Thank you Luciano, I hope my edit explains my thinking further Commented Jul 6, 2016 at 15:42
  • What happens if this text is dynamic so that the ascenders and descenders vary? What rule do you follow then? Commented Jul 6, 2016 at 16:05
  • I only care about Latin text. But thanks for getting me to think about weight. That would be an argument for version 1, because most of the blackness is inside the x-height, with some ascenders and descenders "going out" sometimes.
    – ernesto
    Commented Jul 6, 2016 at 18:05

Design is not always an exact science. Often what looks correct, may not be what is the true center or what is mathematically correct.

Specifically, in your question it would depend on the ascenders and descenders in the text to determine best the optical alignment. If there are no ascenders or descenders, the ideal alignment can change. In your examples, number three seems the best choice because there are both ascenders and descenders and centering them looks the most pleasing to the eye.

  • What happens if this text is dynamic so that the ascenders and descenders vary? What rule do you follow then? Commented Jul 6, 2016 at 16:05
  • Zach, if typography is of the utmost importance you would want to adjust each box manually to where your mind/eye tells you it is balanced (I've spent many hours tweaking the fine details of a design). If you need to make a style that will be repeated often, you can create 3 styles: ascender heavy, descender heavy, and neutral (not sure what software you are using). This too will not be exact, but should turn out somewhat balanced. If a single style is chosen for all text, it may make an easier job of it but, typography will suffer.
    – ispaany
    Commented Jul 6, 2016 at 17:58
  • I'm also more interested in the case where text is dynamic and the style should be reusable (like navigation bars or buttons). It doesn't need to be perfect like when you design a logo or an icon. But how would I create the "neutral" style you mention? Just by eye?
    – ernesto
    Commented Jul 6, 2016 at 18:01
  • @ernesto you have to make a compromise you chose one place that works in one instance and then ignore all the cases where it does not. That's how it works. You just have to accept that you can not win in all cases.
    – joojaa
    Commented Jul 6, 2016 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.