When I specify text-align:center
for an element with a width that is greater than the width of the text, the text is centered within the content box of the element (as expected).
When I specify text-align:center
for an element with a width that is less than the width of the text, the text is aligned to the left edge of the content box and overflows the right edge of the content box.
You can see the two cases in action here.
Can any CSS magic make the text equally overflow both the left edge and the right edge of the content box, so that it stays centered?
white-space: nowrap;
? If not, the text appears centered. – feeelawhite-space:nowrap
in order to keep the text on a single line, which is the desired behavior. – Nathan Ryan