Example 1 — Clear Descenders with under
Keep the underline below subscripts and descenders.
<style>
p {
text-decoration-line: underline;
text-underline-position: under;
}
</style>
<p>H<sub>2</sub>O sample underline</p> How It Works
- Draw the line.
text-decoration-line: underlinecreates the decoration. - Force below.
underplaces it under the alphabetic baseline. - Clear glyphs. Subscripts and descenders (g, y, p) stay readable.
- Global tip. Because it inherits,
:root { text-underline-position: under; }can set a page default.

