7

Questions tagged with (or that use the <!-- language: lang-html --> tag before code blocks) treat # as a single line comment for syntax highlighting like Python. To my knowledge, this is not how you denote a single line comment in HTML. It particularly becomes a problem in questions tagged with in addition to because it displays id selectors (which use #) as single line comments.

I understand that SO uses Google Code Prettify, but this seems like a bit of a large oversight if it is a problem with that service; does anyone use Prettify who can confirm that this is a service-wide issue?

Examples one and two.

1
  • I think it does that with most languages (like CSS).
    – bjb568
    May 11, 2014 at 21:55

1 Answer 1

4

The HTML tag don't use HTML-specific formatting by default. Because posts tagged often have CSS, the generic syntax highlighter is used instead, because it produces half-decent results for both of them.

If you want to invoke the HTML-specific formatting, you need to specify...

<!-- language: lang-html -->
<html>
# hello world
<b>hello</b>
1
  • That's interesting: quite a compromise. Almost defeats the purpose of having auto-syntax-highlighting if then you have to specify not only HTML but CSS as well if you want proper highlights. I guess it works for everything else, though...
    – AstroCB
    May 11, 2014 at 22:41

You must log in to answer this question.

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