I Just Wanted Emacs to Look Nice — Using 24-Bit Color in Terminals (chadaustin.me)
TL;DR: Explanation of why the escape sequence for 256 color and 24 bit color modes are weird and can vary. \E[38:5:nm is technically the correct form for 256 color, but \E[38;5;nm is the form terminals more widely support....