Comment by gjm11
3 days ago
Using a monospaced typeface for that purpose isn't only convention; it reflects the fact that when those commands are typed literally, it will be in a terminal which almost certainly itself uses a monospaced typeface. I think I'd say that setting literal command text in a monospaced face is a best practice.
[EDITED to add:] I agree with the general point about distinguishing best practices from conventions, though. (But there are also intermediate possibilities. "Best practice for us because it fits with conventions we've become used to". "Best practice for us because of some peculiarity of us or our work, even though for other groups it might not be so good".)
The convention is used also for strings entered in a proportional font such as an address bar. I think the primary reason for the convention is most fonts where all characters are distinct are monospaced. But terminals being monospaced typically contributed surely.