Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 157 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

This question already has an answer here:

When using SO's code blocks, can you control how syntax highlighting is performed? Many times, I've pasted (for example) some shell output into an SO answer, and the syntax highlighting has been completely unrelated. Is there any way to turn it off, or to change the language used?

share|improve this question

migrated from Aug 10 '09 at 14:31

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Pops Sep 14 '14 at 22:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 7 down vote accepted

There is a way to completely turn off code highlighting: use <code> tags (I often do this for OCaml/Lisp/Haskell code where unmatched 's cause problems). EDIT: As random pointed out, <pre> will work better than <code>.

Normal highlighting:

return 'a' "x" void

With <pre> it looks like this:

return 'a' "x" void

Keep in mind that with <pre>, you don't need to indent your code by four spaces. For example, the code in this answer is formatted like this:

Normal highlighting:

    return 'a' "x" void

With `<pre>` it looks like this:

return 'a' "x" void

(Sorry about the highlighting but I can't do this in <pre>...)

share|improve this answer
If you want the nice background, use PRE – random Aug 10 '09 at 14:48
Note that it appears that <!-- language: none --> is now the preferred mechanism to disable syntax highlighting for a preformatted block of text. – Phrogz Mar 31 '11 at 22:32

You cannot control how the syntax is highlighted.

SO, uses Google's prettify to do the syntax coloring. Prettify uses common language patterns to determine syntax coloring.

For example:


// comment


'This is a string'
"So is this"

Key words:


As Zifre says. You can turn off the syntax highlighting in code by using the <pre> tags around your desired block of code.

share|improve this answer
So this is a problem upstream? – SingleNegationElimination Sep 10 '09 at 23:20
Hmm... it looks like prettify has the ability to specify a language using a lang-* css class. – SingleNegationElimination Sep 10 '09 at 23:26
Didn't work for me.... <pre class="prettyprint lang-html"> made the code a complete mess. – Joe Casadonte Mar 6 '10 at 13:51

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