Skip to main content

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​

SpecificationSection
VT510 Reference—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✓Yes
Bobcat??Implemented in external TerminalCtrl library, not in Bobcat source code
contour✓v0.1.0
foot✓YesImplemented at csi.c:95-123, supports extended underline styles via SGR 4:n
Ghostty✓v1.0.0
iTerm2✓YesUnderline (SGR 4) fully supported with multiple styles via sub-parameters including single, double, curly, dotted, and dashed.
Kitty✓Yes
Konsole✓YesSGR 4 sets RE_UNDERLINE, supports subparameters for different underline styles
mintty✓YesImplemented at src/termout.c:2122-2124. Sets ATTR_UNDER flag.
mlterm✓YesSupported since early versions
PuTTY✓0.43SGR 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✓YesSGR 4 sets singly underlined style
xterm✓YesVT100 feature, supported since earliest versions
xterm.js✓2.3.0
Multiplexers
cy✓v0.1.0
GNU Screen✓v.4.2.0SGR 4 mapped to A_US attribute at src/ansi.c:1703
tmux✓0.8
tuios✓v0.0.15
Zellij✓v0.12.0

See also​