Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Inline CSS Selector CommentsNew to Visual Studio Code? Get it now.
Inline CSS Selector Comments

Inline CSS Selector Comments

Kaesinol

|
1 install
| (0) | Free
Highlight CSS selector comments inside JavaScript and TypeScript string literals.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Inline CSS Selector Comments

Highlight /* ... */ comments inside CSS selector string literals in JS/TS.

Usage

Put the marker directly in front of the string:

const a = /* css selector */ ".my-class /* class selector */";
const b = /* css selector */ "#app > .title /* ID and child combinator */";
const c = /* css selector */ "input[type='text'] /* attribute selector */";
const d = /* css-selector */ '.single';
const e = /* css selector */ `.tpl .child`;

The selector keeps your theme's normal string color; inner /* ... */ blocks are highlighted as comments.

Before / after

test = /*css-selector*/ "div.card > .title /* comment */";

Before After
before after

The inner /* comment */ now renders in the comment color instead of blending into the string.

Markers

/* css selector */ and /* css-selector */, both supported.

Languages

JavaScript / TypeScript (incl. JSX, TSX), and the <script> block of Vue / Svelte / Astro.

Notes

  • The marker must be a block comment directly in front of the string.
  • Strings without the marker are untouched.
  • Escaped quotes (\") won't terminate the string early.

Configuration

The comments use the scope comment.block.css.inline-selector, which nests under the standard comment scopes, so it is colored like any other comment by default. To color it on its own, without touching comments elsewhere:

// settings.json
"editor.tokenColorCustomizations": {
  "textMateRules": [
    {
      "scope": "comment.block.css.inline-selector",
      "settings": { "foreground": "#C586C0" }
    }
  ]
}

This affects only the comments inside the string. The /* css selector */ marker keeps following your theme's regular comment color, since it uses the standard comment scope.

The color itself is never hardcoded in this extension; it always comes from your theme, so switching themes also switches the comment color.

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft