Want to make Font Awesome icons clickable

HtmlFont Awesome

Html Problem Overview


So I am new to web development and I am trying to link font awesome icons to my social profiles but am unsure of how to do that. I tried using an a href tag but it made all of the icons take me to one site instead of the one I wanted. Here is the code:

 <i class="fa fa-dribbble fa-4x"></i>
 <i class="fa fa-behance-square fa-4x"></i>
 <i class="fa fa-linkedin-square fa-4x"></i>
 <i class="fa fa-twitter-square fa-4x"></i>
 <i class="fa fa-facebook-square fa-4x"></i>

I'd like for each of these icons to go to their respective profiles. Any suggestions?

Html Solutions


Solution 1 - Html

You can wrap those elements in anchor tag

like this

<a href="your link here"> <i class="fa fa-dribbble fa-4x"></i></a>
<a href="your link here"> <i class="fa fa-behance-square fa-4x"></i></a>
<a href="your link here"> <i class="fa fa-linkedin-square fa-4x"></i></a>
<a href="your link here"> <i class="fa fa-twitter-square fa-4x"></i></a>
<a href="your link here"> <i class="fa fa-facebook-square fa-4x"></i></a>

Note: Replace href="your link here" with your desired link e.g. href="https://www.stackoverflow.com".

Solution 2 - Html

If you don't want it to add it to a link, you can just enclose it within a span and that would work.

<span id='clickableAwesomeFont'><i class="fa fa-behance-square fa-4x"></span>

in your css, then you can:

#clickableAwesomeFont {
     cursor: pointer
}

Then in java script, you can just add a click handler.

In cases where it's actually not a link, I think this is much cleaner and using a link would be changing its semantics and abusing its meaning.

Solution 3 - Html

Using bootstrap with font awesome.

<a class="btn btn-large btn-primary logout" href="#">
		<i class="fa fa-sign-out" aria-hidden="true">Logout</i>
</a>

Solution 4 - Html

I found this worked best for my usecase:

<i class="btn btn-light fa fa-dribbble fa-4x" href="#"></i>
<i class="btn btn-light fa fa-behance-square fa-4x" href="#"></i>
<i class="btn btn-light fa fa-linkedin-square fa-4x" href="#"></i>
<i class="btn btn-light fa fa-twitter-square fa-4x" href="#"></i>
<i class="btn btn-light fa fa-facebook-square fa-4x" href="#"></i>

Solution 5 - Html

Please use Like below.
<a style="cursor: pointer" **(click)="yourFunctionComponent()"** >
<i class="fa fa-dribbble fa-4x"></i>
 </a>

> The above can be used so that the fa icon will be shown and also on > the click function you could write your logic.

Solution 6 - Html

In your css add a class:

.fa-clickable {
    cursor:pointer;
	outline:none;
}

Then add the class to the clickable fontawesome icons (also an id so you can differentiate the clicks):

 <i class="fa fa-dribbble fa-4x fa-clickable" id="epd-dribble"></i>
 <i class="fa fa-behance-square fa-4x fa-clickable" id="epd-behance"></i>
 <i class="fa fa-linkedin-square fa-4x fa-clickable" id="epd-linkedin"></i>
 <i class="fa fa-twitter-square fa-4x fa-clickable" id="epd-twitter"></i>
 <i class="fa fa-facebook-square fa-4x fa-clickable" id="epd-facebook"></i>

Then add a handler in your jQuery

$(document).on("click", "i", function(){
	switch (this.id) {
    	case "epd-dribble":
            // do stuff
            break;
        // add additional cases
	}
});

Solution 7 - Html

             <a href="#"><i class="fab fa-facebook-square"></i></a> 
             <a href="#"><i class="fab fa-twitter-square"></i></a> 
             <a href="#"><i class="fas fa-basketball-ball"></i></a> 
             <a href="#"><i class="fab fa-google-plus-square"></i></a>


              All you have to do is wrap your font-awesome icon link in your HTML 
                               with an anchor tag.
        Following this format:
                   <a href="Link here"> <font-awesome icon code> </a>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontiffanywhitedevView Question on Stackoverflow
Solution 1 - Htmlshyammakwana.meView Answer on Stackoverflow
Solution 2 - HtmlNeo M HackerView Answer on Stackoverflow
Solution 3 - HtmlPuneeth Reddy VView Answer on Stackoverflow
Solution 4 - HtmlwattryView Answer on Stackoverflow
Solution 5 - Htmlshuaib View Answer on Stackoverflow
Solution 6 - HtmlEric D'SouzaView Answer on Stackoverflow
Solution 7 - HtmlTimilehinView Answer on Stackoverflow