Possible Duplicate:
Why isn't syntax highlighting working in a question?
Why isn't code coloured as it should be?

I do not get it. If you look at this answer, you can see that the syntax highlight works in the way as i was intended to have it. But the same code does not work in this question

  • Why is that, how can i avoid damageing the syntax highlight?
  • Is it possiblie to force a special syntax?
  • Is there a "good practice" example or tutorial, to avoid bad behavior in highlighting?

1 Answer 1


There's no syntax highlighting because the question is lacking relevant tags.

Tags are used as default syntax highlighting hints. For example, if the question is tagged , then the code will be treated as if it were JavaScript for highlighting purposes. This is the case with the question for which your answer is correctly highlighted, but is not the case for the other question.

So the best solution for questions is just to make sure that they are tagged correctly. That's important for lots of reasons above and beyond syntax highlighting.

If you can't get the tags to apply the syntax highlighting you desire, or you have an answer in which you want to provide snippets of code in multiple languages not mentioned in the question, then you can provide an explicit syntax highlighting hint, as discussed here.


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