Markdown heading in CSS comments

Florens Verschelde

I use Markdown-inspired headings in my CSS comments, to structure my code and make it easier to parse visually and maintain. I tend to use two, sometimes three levels of headings.

For the first two levels, I use a rather verbose syntax. But it’s not too hard to type (especially in the SCSS syntax), and it makes it easier to spot the different headings.

Is it a good style? I don’t know. I’ve only ever used it in my personal projects. But I like it, so I’m sharing it.

/* ================= */
/* LEVEL ONE HEADING */
/* ================= */

/* ----------------- */
/* Level two heading */
/* ----------------- */

/* ### Level three heading ### */
/* Additional information goes here. */

And in SCSS:

// =================
// LEVEL ONE HEADING
// =================

// -----------------
// Level two heading
// -----------------

// ### Level three heading ###
// Additional information goes here.

Differences from Markdown

I’m not using strict Markdown in the heading-comment style above. The main differences are: