17

There are some languages that get highlighted incorrectly. Is it possible to specify a code block that does not have any highlighting when it gets displayed?

Here is an small example of CSS that is getting highlighted as if it was C/C++.

#div.a {
  background-color: #000000;
}

.static {
}
0

2 Answers 2

9

You can display a block without color by using a <pre> block.

#div.a {
    background-color: #000000;
}

.static {

}

And I think StackOverflow is using Google Code Prettify, but I haven't figured out how to get it to show CSS yet (though it claims it should, attaching class="prettyprint lang-css" in a pre tag doesn't seem to work.).

CORRECTION: Oops, apparently StackOverflow uses Google Code Prettify not syntaxhighlighter as was previously posted, thx for the correction shog9, it's always nice to have the right information. Despite the correction, the class="prettyprint lang-css" attribute still doesn't seem to work, even with supported languages such as C.

1
  • It will highlight CSS if the lang-css class is present AND lang-css.js is loaded. Per-language support does not work if the language specific handler is not loaded. Commented Dec 10, 2009 at 18:29
8

Actually, it's Google Code Prettify.

As Akdom noted, you can just use a <pre> tag and leave out the prettyprint class to get a plain ol' code listing. Alternately, we support special comment prefixes to force language-specific highlighting (or turn highlighting off altogether):

<!-- language: lang-css -->

...will properly highlight CSS syntax, while

<!-- language: lang-none -->

...will turn it off.

0