Archived topic
How to retain heading color (vs. link color) when heading is a link
9 replies · Started by Janet on August 8, 2018
I have some heading2's that I'd like to make links, but when I do, they change to the color for links. Is it possible to have a linked heading2 that stays the same color as other heading2's? If so, how?
Hi there,
Where are the H2 links on the page you linked?
I'm not seeing them.
Let me know :)
On home page, http://janetmajure.com. The headings in the columns.
Ah ok those are h3.
So modify the HTML to this:
<h3 class="h3-link"><a href="http://janetmajure.com/editorial/">Editorial Services</a></h3>
Then add this CSS:
h3.h3-link a {
color: #000;
}
Adding CSS: https://docs.generatepress.com/article/adding-css/
Let me know :)
Sorry about mistaken heading ID.
Before I launch, please confirm that I'll need to insert the <h3 class="h3-link"> for each h3 heading I want to use as link.
Also, does it follow that if I want to make links from any other headings and have them retain the heading-defined color, I'll have to define a h4 (for example) class for a link in CSS and add h4 class="h4-link" in the HTML for each heading in question? (Don't think I phrased that well. Let me know if it's confusing.)
Thanks for your response.
That case then maybe try adding the class to the link itself:
<a class="heading-link" href="http://janetmajure.com/editorial/">Editorial Services</a>
Then target with CSS:
.heading-link {
color: #000;
}
Then it shouldn't matter which heading you are using.
Not entirely sure I'm following you, as my coding knowledge is basic. Is the following correct?
1. Add the .heading-link business to the CSS.
2. Add the class definition/association/whatever-it's-called around any heading that I want to act as a link.
Net result will be that any heading so defined will use fallback heading color, even if it's a link.
Is that right?
It should be something like this:
<h2><a class="heading-link" href="http://janetmajure.com/editorial/">Editorial Services</a></h2>
<h3><a class="heading-link" href="http://janetmajure.com/editorial/">Editorial Services</a></h3>
And the CSS would just be:
a.heading-link {
color: #000;
}
Let me know :)
Thanks. I'll take that to mean I will indeed need to manually redo the HTML for each heading/link, even with addition to CSS (but have to do only one CSS addition). Right?
Yeah I'd say that's the easiest way unless you have hundreds of links already.
I only saw three.