I want to highlight the code in comment box, How can do this. I want to highlight my syntax code highlight in comment field


As @Martijn Pieters said

If the code is part of an answer, make it an answer. If the code is to clarify a question, edit the question to include the code.

But still, if you want to add code snippet in comment(minor if some other user need clarification.. and doesn't add much to question ), then you can try adding your code in backticks block (`) ... like this


  • Like this System.out.println("str")
    Oct 12 '13 at 9:28
  • Code in comments is not highlighted, even when written between back ticks. Then, that is the behavior of inline code even with questions and answers.
    – apaderno
    Oct 12 '13 at 10:50

You can't.

Comments are not full-fledged posts, they do not support multiple lines and certainly do not support syntax highlighting.

At best, you can mark text with backticks to be rendered in a typeface font: `typeface font`

If the code is part of an answer, make it an answer. If the code is to clarify a question, edit the question to include the code.

  • thats cool, so y -vote??? i have seen some one commneted me with highlighted code Oct 12 '13 at 9:21
  • check this stackoverflow.com/questions/19316899/… Oct 12 '13 at 9:22
  • Here you can see the commnets got highlighted. is't it????? Oct 12 '13 at 9:23
  • 1
    @DineshKanivu - you can make the code have the grey background with backticks (`) like this but you can't get syntax highlighting more than that. Oct 12 '13 at 9:23
  • @John Palmer Thats only my question. and its possible as u say. Then what is mean by highlighting i mean??? i mean thta only Oct 12 '13 at 9:25
  • @DineshKanivu - syntax highlighting is certain words in different colors - the different colors for language keywords - for example in this post stackoverflow.com/questions/19327506/… Oct 12 '13 at 9:26
  • @DineshKanivu: That is not highlighting; there is no color coding of keywords. That is displaying selected text as teletyped; use backticks for that. Oct 12 '13 at 9:26
  • i am not talking about, i am talking about commnet Oct 12 '13 at 9:27
  • @DineshKanivu: You are using the term highlighting and John is merely showing you what we understand highlighting to mean. Syntax highlighting is only possible in full-fledged posts. What you are talking about is not highlighting. Oct 12 '13 at 9:29
  • Ok leave, all of you guys notice this stackoverflow.com/questions/19316899/…. ok See one of the commnets highlighted its background in grey color. Just tell me how can i do that, instead of showing interest to give -ve vote Oct 12 '13 at 9:29
  • @DineshKanivu - Are you talking about this comment? Oct 12 '13 at 9:34
  • @DineshKanivu add you text in between two back ticks ` as I have answered.. that part will be in grey color indicating code formatting...
    Oct 12 '13 at 9:35
  • @hims056 Yes sir Oct 12 '13 at 9:37
  • @DineshKanivu: We already told you how to do that; use backticks. Different sites will render such text in different ways. Stack Overflow uses a grey background, here on Meta the background colour is white but the font does change: example text in backticks. Oct 12 '13 at 9:38
  • 2
    @DineshKanivu - Have a look at this help page for how to format comments Oct 12 '13 at 9:38

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