SGR 48;5;n — 256-color background
Pick a background color from the 256-color xterm palette.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\\x1b[
\x1b[48;5;Nm\\033[
\033[48;5;Nm\\e[
\e[48;5;NmESC [
ESC [ 4 8 ; 5 ; N mhex
1b 5b 34 38 3b 35 3b <N> 6dDescription
Background sibling of `\x1b[38;5;Nm`. N is 0–255 with the same palette layout: 0–7 basic, 8–15 bright, 16–231 a 6×6×6 RGB cube (`16 + 36*r + 6*g + b`), 232–255 a 24-step grayscale ramp. The colon sub-parameter form `\x1b[48:5:Nm` is also accepted by ECMA-48-strict parsers. Reset just the background with `\x1b[49m`.
Spec citation: xterm-ctlseqs (256-color extension)
Examples
printf '\033[48;5;202m highlight \033[49m\n'print('\x1b[48;5;202m highlight \x1b[0m')fmt.Print("\x1b[48;5;202m highlight \x1b[0m")console.log('\x1b[48;5;202m highlight \x1b[0m')printf("\x1b[48;5;202m highlight \x1b[0m\n");Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- yes
- iTerm2
- yes
- Windows Terminal
- yes
- cmd.exe / ConPTY
- partial
- kitty
- yes
- alacritty
- yes
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- yes
- Konsole
- yes
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | yes | yes | yes | partial | yes | yes | yes | yes | yes | yes | no | no |