HTML Links Different Colors

Yes, you can change the color of HTML links using CSS (Cascading Style Sheets).

Here’s an example of how you can change the color of an HTML link to blue:

<a href="https://www.example.com" style="color: blue;">Example</a>

In the above code, we added the style attribute to the link and set the color property to blue.

You can also create a CSS class for links and apply it to multiple links. Here’s an example:

<style>
  .link {
    color: green;
  }
</style>

<a href="https://www.example1.com" class="link">Example 1</a>
<a href="https://www.example2.com" class="link">Example 2</a>
<a href="https://www.example3.com" class="link">Example 3</a>

In the above code, we created a CSS class called .link and set the color property to green. We then applied the class to multiple links.

You can also use different CSS properties to change the color of links on hover or when they are visited. Here’s an example:

<style>
  a:link {
    color: blue;
  }

  a:hover {
    color: red;
  }

  a:visited {
    color: purple;
  }
</style>

<a href="https://www.example.com">Example</a>

In the above code, we used the :link, :hover, and :visited pseudo-classes to set different colors for the link depending on its state. The :link pseudo-class applies to links that have not been visited, the :hover pseudo-class applies to links when the user hovers over them, and the :visited pseudo-class applies to links that have already been visited.

You may also like...

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *