# CSS for showing heading levels in gutter

**URL:** <https://forum.obsidian.md/t/css-for-showing-heading-levels-in-gutter/72244>\
**Category:** Devs: Theme Design & Custom CSS\
**Tags:** windows, custom-css, android, mobile\
**Created:** [December 1, 2023, 12:03am UTC](https://forum.obsidian.md/t/css-for-showing-heading-levels-in-gutter/72244 "2023-12-01T00:03:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![woofy31](https://forum.obsidian.md/user_avatar/forum.obsidian.md/woofy31/32/57279_2.png) [@woofy31](https://forum.obsidian.md/u/woofy31)\
**Post date:** [December 1, 2023, 1:12am UTC](https://forum.obsidian.md/t/css-for-showing-heading-levels-in-gutter/72244/2 "2023-12-01T01:12:35Z")

</div>

OK, so here’s a CSS snippet I came up with that works in all 3 viewing modes _(and hides when editing the header)_, although I haven’t tested it on mobile but should work just fine _(preview images below)_:

```css
:root {
  --hh-gutter-margin: 0;
  --hh-marker-size: 65 / 100;
}

h1:before, .HyperMD-header-1:not(.cm-active):before {
  content: "H1 ";
  font-size: calc(var(--h1-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}
h2:before, .HyperMD-header-2:not(.cm-active):before {
  content: "H2 ";
  font-size: calc(var(--h2-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}
h3:before, .HyperMD-header-3:not(.cm-active):before {
  content: "H3 ";
  font-size: calc(var(--h3-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}
h4:before, .HyperMD-header-4:not(.cm-active):before {
  content: "H4 ";
  font-size: calc(var(--h4-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}
h5:before, .HyperMD-header-5:not(.cm-active):before {
  content: "H5 ";
  font-size: calc(var(--h5-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}
h6:before, .HyperMD-header-6:not(.cm-active):before {
  content: "H6 ";
  font-size: calc(var(--h6-size) * var(--hh-marker-size));
  margin-left: var(--hh-gutter-margin);
}

```

Result with `--hh-gutter-margin: -20px` (that is, the heading markers are slightly offset to the left of the main content):

> ![Screenshot-01_12_2023-03.10.05](https://forum.obsidian.md/uploads/default/original/3X/4/8/48d35e41df0a64dfe301e764cdcc0e0ff6e20d76.jpeg)

Result with `--hh-gutter-margin: 0` (that is, no offset so heading markers are inline with the main content):

> ![Screenshot-01_12_2023-03.10.15](https://forum.obsidian.md/uploads/default/original/3X/a/9/a9af5406ebdec8332111e0adbb8bca6020c46dd3.jpeg)

NOTE: you can also adjust the size of the marker with `--hh-marker-size`, which is a percentage as you may have noticed and as @holroy realized was a better way of achieving this than using random divisions as I initially did.

---

_[View the full topic](https://forum.obsidian.md/t/css-for-showing-heading-levels-in-gutter/72244)._
