Home > Article > Web Front-end > What does ex mean in css
Ex in css is a relative length unit, which represents the "x-height" length relative to the current font, that is, relative to the height of the character "x", which is usually half the font height. The syntax is " Size attribute: value ex;".
The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.
What does ex mean in css
Ex in css is a relative length unit.
CSS has several different units for representing length.
Many CSS properties accept "length" values, such as width, margin, padding, font-size, etc.
Length is a number followed by the length unit, such as 10px, 2em, etc.
Relative length units specify the length relative to another length attribute. Relative length units scale better between different rendering media.
ex represents the "x-height" length relative to the current font. The example is as follows:
<html> <head> <style> div { font-size: 30px; border: 1px solid black; } span { font-size: 1ex; } </style> </head> <body> <div>这个 div 元素的 font-size 被设置为 30px。<span>div 元素内部的 span 元素的 font-size 为 1ex。</span></div> </body> </html>
Output result:
(Learn Video sharing: css video tutorial)
The above is the detailed content of What does ex mean in css. For more information, please follow other related articles on the PHP Chinese website!