# Hide or Truncate URLs in Editor using CSS? (one year later)

**URL:** <https://forum.obsidian.md/t/hide-or-truncate-urls-in-editor-using-css-one-year-later/23662>\
**Category:** Help\
**Created:** [September 4, 2021, 1:52pm UTC](https://forum.obsidian.md/t/hide-or-truncate-urls-in-editor-using-css-one-year-later/23662 "2021-09-04T13:52:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![looper](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/l/c0e974/32.png) [@looper](https://forum.obsidian.md/u/looper)\
**Post date:** [September 4, 2021, 1:52pm UTC](https://forum.obsidian.md/t/hide-or-truncate-urls-in-editor-using-css-one-year-later/23662/1 "2021-09-04T13:52:17Z")

</div>

I’d like to implement what’s described at this other post [Hide or Truncate URLs in Editor using CSS? - Resolved help - Obsidian Forum](https://forum.obsidian.md/t/hide-or-truncate-urls-in-editor-using-css/359/14) to solve the problem explained there:

“Some URLs [in the editor view] are very long…Without having to use a URL shortener of some kind, is there some way to use CSS that could hide this from view in the editor?”

I tried the CSS solution found there, but while it shortens URLs beautifully, if you try to edit a URL, weird things happen instead:

- if you try to edit by mouse selection, the URL reverts to the symbol replacement
- if you try to use Backspace or Delete keys on the keyboard, it deletes text after the URL instead
- using the arrow keys, you can navigate the first line of the URL, but if the URL wraps to multiple lines, the cursor cannot go to the 2nd or later line (the URL will revert to the symbol)

I’m wondering if maybe the CSS worked in previous versions of Obsidian but is now broken.

Here’s the CSS in question:

```auto
    font-size: 0;
}
div:not(.CodeMirror-activeline) > .CodeMirror-line .cm-string.cm-url:not(.cm-formatting)::after {
    content: '🔗';
    font-size: 1rem;

```

Edit: I think this is prob. how it always behaved. For now I’m using a link-shortening service as a workaround instead of the CSS.

Edit #2: At least the mouse-selecting portion of this bug was previously known. At the moment all of the buggy behavior is resolved by the CodeMirror Options plugin, mentioned here: [CSS 'Active Line' Fails When Highlighting Text - #5 by jokysatria](https://forum.obsidian.md/t/css-active-line-fails-when-highlighting-text/4036/5)

---

<div class="post-metadata">

**Author:** ![macedotavares](https://forum.obsidian.md/user_avatar/forum.obsidian.md/macedotavares/32/139_2.png) [@macedotavares](https://forum.obsidian.md/u/macedotavares)\
**Post date:** [September 7, 2021, 4:29pm UTC](https://forum.obsidian.md/t/hide-or-truncate-urls-in-editor-using-css-one-year-later/23662/2 "2021-09-07T16:29:15Z")

</div>

I know you didn’t ask for advice on this, but here’s mine:

Don’t use URL shorteners on your notes — not if you want them to be useful in 10 years, at least. The chances of the website itself being up by then are slim to begin with; if you throw an external service in there, that’s one more place where things can break. (Not to mention that the URL becomes a lot less informative.)

I have **huge** strings of multiple URLs for each website I intend to keep, and I’d really like to hide them from view, but the upside is that I have full html backups on Dropbox and archive.is snapshots. I think it’s worth it.

---

<div class="post-metadata">

**Author:** ![anon12638239](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/a/2bfe46/32.png) [@anon12638239](https://forum.obsidian.md/u/anon12638239)\
**Post date:** [September 7, 2021, 4:49pm UTC](https://forum.obsidian.md/t/hide-or-truncate-urls-in-editor-using-css-one-year-later/23662/3 "2021-09-07T16:49:04Z")

</div>

You can use [reference-style markdown links](https://daringfireball.net/projects/markdown/syntax#link) and dump long URLs at the bottom of notes.

Angel

```markdown
You can use [reference-style markdown links][1] and dump long URLs at the bottom of notes.

[1]: https://daringfireball.net/projects/markdown/syntax#link

```

---

<div class="post-metadata">

**Author:** ![looper](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/l/c0e974/32.png) [@looper](https://forum.obsidian.md/u/looper)\
**Post date:** [September 9, 2021, 2:16pm UTC](https://forum.obsidian.md/t/hide-or-truncate-urls-in-editor-using-css-one-year-later/23662/4 "2021-09-09T14:16:26Z")

</div>

Thanks; that’s a good point. At the moment I’m using the plugin CodeMirror Options which fixes the CSS bug so I don’t have to use a link-shortening service. The author of the plugin thinks it might break soon but…we’ll cross that bridge then…

---

<div class="post-metadata">

**Author:** ![looper](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/l/c0e974/32.png) [@looper](https://forum.obsidian.md/u/looper)\
**Post date:** [September 9, 2021, 2:23pm UTC](https://forum.obsidian.md/t/hide-or-truncate-urls-in-editor-using-css-one-year-later/23662/5 "2021-09-09T14:23:11Z")

</div>

Ah, that’s pretty cool. The disadvantage is that when in Edit mode, I can’t Ctrl-click or Alt-Enter on the reference link to open the webpage (or even to jump down to the footnote, I don’t think)…

At the moment, I’m using the CodeMirror plugin, which fixes the CSS bug. So, problem solved for now! Thank you for the recommendation though. It’s definitely one solution.

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [October 9, 2021, 2:24pm UTC](https://forum.obsidian.md/t/hide-or-truncate-urls-in-editor-using-css-one-year-later/23662/6 "2021-10-09T14:24:08Z")

</div>

Closed on October 9, 2021, 2:24pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
