Skip to content

Recommended CSS snippet: Hide HTML comments on non-active lines #37

@vergenzt

Description

@vergenzt

Hi! I just came up with this snippet for my own use and figured I'd share it:

edited 2025-04-09 Wed to account for #37 (comment):

/* filename: .obsidian/snippets/hide-non-active-comments.css */
/* Hide HTML comments in non-active lines (displays as `<-- …`) */
.cm-line:not(.cm-active) .cm-comment:not(.cm-hmd-codeblock) {
  display: block;
  max-width: 5ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

Screenshots

Without the snippet:

Image

With the snippet, cursor not on any comment line:

Image

With the snippet, cursor on first comment line:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions