I am in the process of designing a website and I have a specific vision for how I want my links to appear, but I am unsure of how to achieve it.
Here is the desired outcome:
a red link
a green link
a red link
a green link
…
Below is the HTML code I have so far:
<div id="aRandomDivforThisQuestion">
<a href="#">a red link</a>
<p>
<a href="#">a green link</a>
<a href="#">a red link again</a>
</p>
<a href="#">yet again a green link</a>
</div><!-- /aRandomDivForThisQuestion -->
Here is the CSS I attempted to use, which did not achieve the desired effect:
#aRandomDivforThisQuestion a:nth-of-type(odd) {
border-bottom: 1px solid red;
color: red;
}
#aRandomDivforThisQuestion a:nth-of-type(even) {
border-bottom: 1px solid #3DCD7C;
color: #3DCD7C;
}
In essence, I want every a
tag within the element with the ID aRandomDivForThisQuestion
to follow this specified pattern, regardless of its nesting level within the div.
Can anyone provide me with a solution?
PS: Whether it's a CSS method, JavaScript approach, jQuery technique, or any other solution, I am open to suggestions.