Code blocks predominantly containing HTML are always highlighted as CSS the moment a question bears the css tag, regardless of whether or not the html tag is present. I always need to force HTML blocks in css questions and their answers to highlight correctly using the
<!-- language: lang-html -->
or
<!-- language-all: lang-html -->
hints.
EDIT: I've found that including the xhtml tag also causes (X?)HTML to be correctly highlighted without the need for hints (see for example this question), but I don't think I should need to add/replace tags to fix this kind of problem.
IME, it's highly unlikely that a code block starting with a <
character is CSS, as <
isn't seen anywhere in CSS code except within strings and comments. Even if, in a block, CSS is embedded within HTML <style>
tags, as long as I make that block highlight as HTML, the content of the <style>
tags also correctly highlights as CSS anyway:
<style type="text/css">
/* This is CSS */
.example {
color: red;
}
</style>
<!-- This is HTML -->
<p class="example">See? Even meta does it right.</p>
The only corner case I can think of is when HTML and CSS are trapped in a single code block like this without any <style>
tags:
<p class="example">HTML paragraph.</p>
.example {
color: red;
}
Other than that, if the syntax highlighter can already sniff HTML/XML blocks in other questions (based in part on the <
character), what stops it from doing so for css questions?