5

Based on https://stackoverflow.com/editing-help#syntax-highlighting I shouldn't need to give the lang- prefix when specifying a language for a tag, however this doesn't appear to be the case for CSS.

This is the result of specifying just <!-- language: css --> on a block of code:

css no prefix

Notice how the IDs (#) are being treated as comments rather than style declarations, and there is no nice formatting on the property names.

This is the result of specifying <!-- language: lang-css --> on the same block of code:

css with prefix

I'm not 100% sure if this is a problem, but if it is: can this be fixed?

3
  • You need to have the [css] tag in the question in order to use <!-- language: css -->.
    – Antony
    Commented May 30, 2013 at 21:38
  • 1
    @Antony this isn't the case. stackoverflow.com/q/16845844/1317805 is the question that code block is from and that question does have the CSS tag. Commented May 30, 2013 at 21:39
  • <!-- language: css --> works on your question here without any code related tags.
    – Antony
    Commented May 30, 2013 at 21:51

1 Answer 1

5

I shouldn't need to give the lang- prefix when specifying a language for a tag

Not exactly. What the help says is that you can use the lang- prefix or

...you can specify a tag, and the syntax highlighting language associated with this tag will be used

(emphasis mine)

The syntax highlighting association for the tag is the default highlighter, not the lang-css one.

4
  • 1
    In that case, can the highlighting association be changed to point to the lang-css one? It's not like the CSS tag isn't popular. Commented May 30, 2013 at 21:52
  • 3
    You'll want to take a look at the discussion on What's happening to syntax highlighting for [css] questions? for why this is the current behaviour.
    – Tim Stone
    Commented May 30, 2013 at 21:54
  • @JamesDonnelly: There is no highlighting association for the CSS tag because posts in that tag typically also have some HTML in them, and you don't want that to be highlighted as CSS.
    – hammar
    Commented May 30, 2013 at 21:55
  • Hmm I see. Thanks, @TimStone. Commented May 30, 2013 at 21:56

You must log in to answer this question.

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