Home >Web Front-end >CSS Tutorial >What does ex mean in css

What does ex mean in css

WBOY
WBOYOriginal
2021-12-22 14:32:223565browse

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;".

What does ex mean in css

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:

What does ex mean in css

(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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn