I am trying to create a multicolor link. I have tried a couple of variations, none of which work.

<a href="URL">Black text <span style="color:red">red text</span> black test</a>
<a href="URL">Black text <span class="rd">red text</span> black test</a>

Does anyone know how to do this?

Recommended Answers

All 2 Replies

Your first link is correct styling the red text. However, its a hyperlink so the other text is not of black color by default. For example, this would work...

<a href="URL">
  <span style="color:black;">Black text</span>
  <span style="color:red">red text</span>
  <span style="color:black;">black text</span>
</a>

Thanks.

I had already defined links to be black. The following code worked.

<a href="URL">
  <span >Black text</span>
  <span style="color:red">red text</span>
  <span >black text</span>
</a>

Suprisingly the following code did not

<a href="URL">
  Black text
  <span style="color:red">red text</span>
  black text
</a>

Perhaps it something weird elsewhere in my style sheet.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.