Underline
AI-Generated Content
This page was generated with the assistance of AI and may contain inaccuracies. It is intended as a placeholder for future human verification. If you spot issues ahead of its initial review, please report them on GitHub!
Standard
Underline (SGR 4) is an SGR attribute that renders text with an underline below the baseline.
Syntax
CSI 4 m SGR 4 — Single underline
CSI 24 m SGR 24 — Not underlined
Formal syntax
SGR-underline = 0x1b, "[", "4", "m" ; SGR-not-underline = 0x1b, "[", "24", "m" ;
Description
Per ECMA-48 §8.3.117, SGR parameter 4 selects "singly underlined." A line is drawn below the text baseline.
Underline is reset by SGR 24 or SGR 0. SGR 24 cancels all underline variants (single, double, curly, dotted, dashed).
Some terminals support extended underline styles using the sub-parameter syntax SGR 4:n where n specifies the style. This is based on ITU-T T.416 and the Kitty underline extension. The basic SGR 4 (equivalent to SGR 4:1) selects a single straight underline.
The underline color defaults to the foreground color but can be overridden with SGR 58 (underline color).
Examples
printf '\e[4mUnderlined text\e[24m Normal text\n'
printf '\e[4;31mRed underlined text\e[0m\n'
Specifications
| Specification | Section |
|---|---|
| VT510 Reference | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | |
| Bobcat | ? | ? | Implemented in external TerminalCtrl library, not in Bobcat source code |
| contour | ✓ | v0.1.0 | |
| foot | ✓ | Yes | Implemented at csi.c:95-123, supports extended underline styles via SGR 4:n |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✓ | Yes | Underline (SGR 4) fully supported with multiple styles via sub-parameters including single, double, curly, dotted, and dashed. |
| Kitty | ✓ | Yes | |
| Konsole | ✓ | Yes | SGR 4 sets RE_UNDERLINE, supports subparameters for different underline styles |
| mintty | ✓ | Yes | Implemented at src/termout.c:2122-2124. Sets ATTR_UNDER flag. |
| mlterm | ✓ | Yes | Supported since early versions |
| PuTTY | ✓ | 0.43 | SGR 4 sets ATTR_UNDER at terminal.c:4652-4655 |
| Rio | ✓ | v0.0.3 | |
| rxvt-unicode | ✓ | 1.2 | |
| st | ✓ | 0.1 | |
| terminology | ✓ | v0.1.0 | |
| VT100 | ✓ | Yes | |
| VTE | ✓ | Yes | |
| WezTerm | ✓ | Yes | |
| Windows Terminal | ✓ | Yes | SGR 4 sets singly underlined style |
| xterm | ✓ | Yes | VT100 feature, supported since earliest versions |
| xterm.js | ✓ | 2.3.0 | |
| Multiplexers | |||
| cy | ✓ | v0.1.0 | |
| GNU Screen | ✓ | v.4.2.0 | SGR 4 mapped to A_US attribute at src/ansi.c:1703 |
| tmux | ✓ | 0.8 | |
| tuios | ✓ | v0.0.15 | |
| Zellij | ✓ | v0.12.0 | |
See also
- Double underline — SGR 21 — Double underline
- Curly underline — SGR 4:3 — Wavy/curly underline
- Underline color (indexed) — Set underline color