I want to change the color of the internal-link, while keeping the color of the external-link as default. I use the CSS suggested in Setting separate internal and external link colors in 1.5.11 as follows:
body:is(.theme-dark, .theme-light) {
--link-color: rgb(249, 166, 138);
--link-color-hover: rgb(252, 197, 182);
}
a.external-link,
.markdown-source-view.mod-cm6
:is(.cm-link, .cm-url, .cm-link .cm-underline, .cm-url .cm-underline) {
color: rgb(166, 138, 249);
}
a.external-link:hover,
.markdown-source-view.mod-cm6
:is(.cm-link:hover, .cm-url:hover, .cm-link .cm-underline:hover, .cm-url .cm-underline:hover) {
color: rgb(197, 182, 252);
}
where internal-link color rgb(249, 166, 138)
and rgb(252, 197, 182)
are orange and light orange, repectively, and external-link color rgb(166, 138, 249)
and rgb(197, 182, 252)
are default purple and default light purple, respectively.
Everything works fine in reading view, as shown in the image below:
In editing view, however, I found two problems that confused me, as shown in the image below:
- Color of Internal Markdown links remains unchanged (both when displaying and editing)
- Color of Internal Markdown links remains unchange when editing in table
I’ve searched and tried a lot but nothing seems to work. I think the best solution which I expect is to find all internal-links and change the color, not to change the color of all links and then change the color of the external-links back to default.
Thanks advanced for your help!
References
- Nov 2023, Styling internal links with a different color
- Mar 2024, Setting separate internal and external link colors in 1.5.11
- Oct 2024, How to change internal and external link color in the live preview & reading view?
Code
## Linking Notes and Files
- Internal Wikilink: [[Obsidian]], [[Obsidian#Internal links]]
- Internal Markdown: [Obsidian](Obsidian.md), [Obsidian#Internal links](Obsidian.md#Internal%20links)
- External URL: https://help.obsidian.md
- External Markdown: [Obsidian Help](https://help.obsidian.md)
| Type | Code 1 | Example 1 | Code 2 | Example 2 |
| ----------------- | ------------------------------------------- | ----------------------------------------- | --------------------------------------------------------- | ------------------------------------------------------- |
| Internal Wikilink | `[[Obsidian]]` | [[Obsidian]] | `[[Obsidian#Internal links]]` | [[Obsidian#Internal links]] |
| Internal Markdown | `[Obsidian](Obsidian.md)` | [Obsidian](Obsidian.md) | `[Obsidian#Internal links](Obsidian.md#Internal%20links)` | [Obsidian#Internal links](Obsidian.md#Internal%20links) |
| External URL | `https://help.obsidian.md` | https://help.obsidian.md | | |
| External Markdown | `[Obsidian Help](https://help.obsidian.md)` | [Obsidian Help](https://help.obsidian.md) | | |