Sharlene Roberts
Sharlene Roberts

Reputation: 145

How to make icon clickable

I have some awesome icons that I would like to direct to a link when clicked. I tried wrapping them in anchor tags, but that doesn't work for some reason, what can I do? I tried two implementations.

    <a href ="Login.php">
        <li class="nav-item border rounded-circle mx-2 cart-icon">
            <i class="fas fa-shopping-cart p-2"></i>
        </li>
    </a>
    <li class="nav-item border rounded-circle mx-2 cart-icon">
        <a href="Login.php"><i class="fas fa-shopping-cart p-2"></i></a>
    </li>

Upvotes: 0

Views: 3566

Answers (1)

user8967105
user8967105

Reputation:

Remove the list, it's not needed

<html>
<head>
<script src="https://kit.fontawesome.com/2442adcce2.js" crossorigin="anonymous"></script> 
 </head>
 <body>
 <a href ="https://www.w3schools.com">
            <i class="fas fa-shopping-cart p-2"></i>
 </a> 
</body>
</html>

This works perfectly, feel free to reply if it doesn't work. I've tested it to make sure.

Upvotes: 1

Related Questions