Source note for styling techniques inside Obsidian notes — rendering tricks, their gotchas, and when to use which. First section grew out of the color work in Color & Skin Tone.

Color chip previews

Three ways to render color swatches in a note, with a shared gotcha to avoid first.

The tag-collision gotcha

A bare hex like #B87C50 anywhere in Markdown source is valid Obsidian tag syntax (letters+digits after #), so it registers in the tag index and renders as a tag pill. This applies even to hexes inside inline-HTML content. Rules:

  • In prose: backtick the hex (`#B87C50`) — code spans are excluded from tag parsing.
  • Inside HTML content (e.g. a pill’s visible text): write the hash as the HTML entity # — renders and copies as #, never matches as a tag.
  • Inside HTML style attributes: bare hexes are safe as-is (the tag parser doesn’t reach into attributes).
  • Inside codeblocks (including palette blocks): safe as-is.

Option 1 — Color Palette plugin (block-level)

The Color Palette plugin renders a palette codeblock as an interactive swatch strip (select to copy; supports hex/RGB/HSL, gradients, coolors/colorhunt links).

```palette
#95303E
#4F5054
{"aliases": ["17 Red (wine)", "07 Gray (charcoal)"], "height": 100, "hover": false}
```

Settings (specified as JSON on the last line): height, width (caution — can deform palettes), direction (column default = side-by-side vertical stripes; row = stacked horizontal bars), gradient, hover, hideText, override (allows CSS variables), aliases (array, positional, "" to skip).

Key setting: "hover": false makes the hex + alias text always visible — with the default (hover on), text only appears on mouse-over/touch. Use hideText: true for the opposite.

Limitation: block-level only. No inline mode exists — the plugin only registers a codeblock processor, so palettes cannot sit mid-sentence or inside table cells. For those, use Option 2.

Option 2 — HTML pill span (inline, works anywhere)

A self-labeled pill — hex text rendered on its own color as background. Works inline in prose and inside table cells; renders in Reading view and Live Preview (shows raw markup in source mode).

<span style="background:#95303E;color:#FFF;text-shadow:-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000;padding:1px 8px;border-radius:3px;font-family:monospace;display:inline-block;white-space:nowrap;min-width:72px;text-align:center">&#35;95303E</span>

Design decisions baked into that template:

  • White text + 4-direction black text-shadow fakes a 1px outline legible on any background color. Preferred over -webkit-text-stroke, which strokes inward and mangles thin monospace glyphs at small sizes.
  • Light pills (roughly B > 70%) additionally get border:1px solid #888 so the pill edge shows against the page.
  • display:inline-block; white-space:nowrap; min-width:72px; text-align:center stops the hex wrapping mid-value and sets a floor width, which effectively sets a minimum table-column width on mobile (Markdown columns size to content).
  • The visible # is the &#35; entity (see gotcha above).

For real column-width control beyond the pill floor, inline styles can’t target columns — use a CSS snippet keyed to a cssclasses frontmatter value, e.g. .color-note table td:last-child { min-width: 10em; } in .obsidian/snippets/ (syncs with the vault via iCloud; enable per device under Settings → Appearance → CSS snippets).

Option 3 — Color Preview plugin (inline, automatic)

The Color Preview plugin adds automatic inline color dots next to hex codes, plus richer color cards and click-to-edit/copy. Zero markup needed — but it keys off bare #hex in source, which collides with the tag-index hygiene above. Untested whether it also detects backticked hexes; if it does, it combines cleanly with the rules here. Not currently installed; Color Palette (Option 1) is.