87

I reviewed an edit that did no change to the post apart from introducing code formatting like this to words that aren't code, such as iOS and Android (while curiously leaving Delphi untouched). I didn't really see the point of this so I rejected the edit as too minor, only to see it had already been approved.

Is there some guideline that OS names should use code formatting? To me, it seems the change does little to improve the post and shouldn't have been approved, but since several reviewers disagreed I believe I should ask it here.

Return to FAQ index

0

2 Answers 2

151

Code formatting shouldn't be used for emphasis on regular words. As for what it should be used for, I don't know if it's possible to make a definitive list, nor to get the community to agree on every item in the list.

Some places where I think code formatting is useful:

  • Micro-snippets of code (This is especially important for HTML tags or things that resemble HTML tags, since some HTML is allowed in posts and the site will try to render anything between < and >)
    • init()
    • if (boolean) {
    • <form action="..." method="post">
    • <strong>
    • <level>
    • &nbsp;
  • Filenames and filepaths
    • readme.txt
    • .htaccess
    • C:\windows\system32
  • Showing a URL that you don't want to render into something clickable
    • http://www.example.com
  • Error code, especially when
    • The code is meant to be in a monospaced font

      01-25 22:13:18.594: DEBUG/skia(4204): xxxxxxxxxxx jpeg error 20 Improper call to JPEG library in state %d
      01-25 22:13:18.604: INFO/System.out(4204): resolveUri failed on bad bitmap uri: 
      01-25 22:13:18.694: ERROR/dalvikvm-heap(4204): 6291456-byte external allocation too large for this process.
      01-25 22:13:18.694: ERROR/(4204): VM won't let us allocate 6291456 bytes
      01-25 22:13:18.694: DEBUG/skia(4204): xxxxxxxxxxxxxxxxxxxx allocPixelRef failed
      
    • The code contains spacing that is lost if it isn't pre-formatted

…but not much more beyond that.

5
  • Also, you know, actual code.
    – M. Justin
    Jan 15, 2021 at 22:11
  • The error code example is about code blocks, but everything else, including the question, appears to be discussing inline code spans. Should that really be included in this answer (and/or should a single-line example be chosen)?
    – M. Justin
    Jan 15, 2021 at 23:41
  • 1
    @M.Justin Already covered in the answer by "Micro-snippets of code". Let me move that item up to the top of the list, though. Also, the indentation here was apparently broken by the CommonMark migration, so I've fixed that, too. Jan 16, 2021 at 0:57
  • I find it's a good way to indicate search strings without confusion about punctutation marks, e.g.: Have you tried using <your favorite search engine> to look for wombat query vms? Searches for bacon levitation and "bacon levitation" tend to be quite different.
    – HABO
    Jan 17, 2021 at 4:21
  • 1
    The style I've settled on for writing documentation/instructions is to use monospace text to indicate UI elements or other text the user might encounter (e.g. "Click the OK button to close the Preferences dialog"), and I've carried that over to Stack Overflow/Exchange. Care must be taken and context must be given to adequately separate it from actual code so it's not mistaken as such, but I think monospace makes more sense for that purpose than using "quotes" and especially bold or italics. Apr 1, 2022 at 21:36
55

Code formatting should never be used for non-code text, except in very limited circumstances such as filenames, URLs, etc.

The use of backticks to emphasise individual words is especially pernicious.

Any suggested edit that adds such formatting should be rejected.

If you see any posts that use it edit it out along with fixing as many of the other problems with the post as you can.

1
  • "such formatting should be rejected", we could rather improve the edit using bold to emphasize and italic for special terms or titles, the HTML-kbd tag for shortcuts like <kbd>Shift</kbd>.
    – hc_dev
    Jan 5 at 20:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .