How to change internal and external link color in the live preview & reading view?

I have a CSS snippet that changes the color of both internal and external links to be this particular shade of red (#F83E43). However, the snippet only works for the reading view and not both as I would like it to be. In the live preview, the links are a lighter color of the custom accent color I have set; which is the same shade of red. (#F83E43)

Here’s the code to the snippet:

/* Default color for all links in both views */
.markdown-preview-view a, .cm-s-obsidian a {
  color: #F83E43 !important; /* Default color for all links */
}

/* External link color in both views */
.markdown-preview-view a.external-link, .cm-s-obsidian a.external-link {
  color: #4CAF50; /* External links color */
}

/* Unresolved (non-existent) links color in both views */
body .markdown-preview-view a.is-unresolved, 
body .cm-s-obsidian .cm-hmd-internal-link.cm-hmd-unresolved,
body .cm-s-obsidian span.cm-hmd-unresolved {
    color: #721e21 !important; /* Darker color for unresolved links */
}

/* Dotted underline on hover for unresolved links in reading view */
body .markdown-preview-view a.is-unresolved:hover {
    text-decoration: underline dotted !important;
}

/* Dotted underline on hover for unresolved links in editing view */
body .cm-s-obsidian .cm-hmd-internal-link.cm-hmd-unresolved:hover,
body .cm-s-obsidian span.cm-hmd-unresolved:hover {
    text-decoration: underline dotted !important;
}

Any help to fix this is greatly appreciated!

It may be a theme issue. As is, your snippet is coloring mostly all links #F83E43 because of the color: #F83E43 !important; line.

Live Preview | Reading view

You could have a look through a similar topic and try some of the suggestions there:

This thread helped, thank you. Specifically the “:root” solution!

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