Creating a Cool Social Media Links for Websites using HTML and CSS Tutorial

In this tutorial, we'll guide you through the process of crafting an engaging and interactive user interface featuring stylish Cool Hoverable Social Media Links/Buttons with subtle animations using HTML and CSS. This tutorial serves as a valuable resource, particularly for newbies and students seeking to learn essential web design techniques. Within this tutorial, we'll furnish you with the source code for a straightforward web page that includes these captivating Social Media Links/Buttons.

Understanding Social Media Links on Websites

Social Media Links refer to the external links on a website that direct users to the social media pages of organizations or companies. They play a pivotal role in a website's link-building strategy, creating additional organic avenues to expand a company's or organization's brand presence within a target market.

What Type of Social Media Links UI Are We Creating?

In this tutorial, we'll offer HTML and CSS code snippets to guide you in building a Social Media Links UI with a clean, yet creative design for your forthcoming website or web application projects. This Social Media Links UI features icons, text, and subtle sliding or expanding animations upon hovering over each link.

What You Need?

For this straightforward web application development using HTML and CSS, you will only require the following:

  • Text Editor: You can use tools like Notepad++, Sublime Text, or VS Code.
  • Web Browser: Any modern browser such as Chrome, Mozilla Firefox, or MS Edge will suffice.

Constructing Page Elements

Our initial step is to establish the application's index file. Open your preferred text editor and create a new HTML file, saving it as index.html. This file encompasses the essential HTML elements for the page interface, including the Social Media Links anchor tags and corresponding icons. We'll be utilizing a CDN to load the Fontawesome library for these icons.

Below, you'll find the HTML code I've prepared for this tutorial:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <meta charset="UTF-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  5. <title>Cool Hoverable Social Media Link | SourceCodester </title>
  6. <!-- Fontaweseome -->
  7. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
  8. <link rel="stylesheet" href="styles.css">
  9. </head>
  10. <main>
  11. <div id="wrapper">
  12. <h2 class="title">Cool Hoverable Social Media Link</h2>
  13. <!-- SocMed Links -->
  14. <div id="soc-med-links">
  15. <!-- Social Media Link Item -->
  16. <div class="soc-med-links-item">
  17. <a href="https://www.facebook.com/SourceCodester" target="_blank">
  18. <!-- Social Media Link Item Icon Element -->
  19. <div class="soc-med-links-item-icon bg-primary">
  20. <i class="fa-brands fa-facebook-f"></i>
  21. </div>
  22. <!-- Social Media Link Item Text Element -->
  23. <div class="soc-med-links-item-text">
  24. SourceCodester
  25. </div>
  26. </a>
  27. </div>
  28. <!-- Social Media Link Item -->
  29. <div class="soc-med-links-item">
  30. <a href="https://twitter.com/intent/follow?original_referer=https%3A%2F%2Fwww.sourcecodester.com%2F&region=follow_link&screen_name=sourcecodester" target="_blank">
  31. <!-- Social Media Link Item Icon Element -->
  32. <div class="soc-med-links-item-icon bg-secondary">
  33. <i class="fa-brands fa-x-twitter"></i>
  34. </div>
  35. <!-- Social Media Link Item Text Element -->
  36. <div class="soc-med-links-item-text">
  37. SourceCodester
  38. </div>
  39. </a>
  40. </div>
  41. <!-- Social Media Link Item -->
  42. <div class="soc-med-links-item">
  43. <a href="https://github.com" target="_blank">
  44. <!-- Social Media Link Item Icon Element -->
  45. <div class="soc-med-links-item-icon bg-dark">
  46. <i class="fa-brands fa-github"></i>
  47. </div>
  48. <!-- Social Media Link Item Text Element -->
  49. <div class="soc-med-links-item-text">
  50. GitHub
  51. </div>
  52. </a>
  53. </div>
  54. <!-- Social Media Link Item -->
  55. <div class="soc-med-links-item">
  56. <a href="https://www.instagram.com/" target="_blank">
  57. <!-- Social Media Link Item Icon Element -->
  58. <div class="soc-med-links-item-icon bg-gradient">
  59. <i class="fa-brands fa-instagram"></i>
  60. </div>
  61. <!-- Social Media Link Item Text Element -->
  62. <div class="soc-med-links-item-text">
  63. Instagram
  64. </div>
  65. </a>
  66. </div>
  67. <!-- Social Media Link Item -->
  68. <div class="soc-med-links-item">
  69. <a href="https://www.youtube.com/@sourcecodester247" target="_blank">
  70. <!-- Social Media Link Item Icon Element -->
  71. <div class="soc-med-links-item-icon bg-red">
  72. <i class="fa-brands fa-youtube"></i>
  73. </div>
  74. <!-- Social Media Link Item Text Element -->
  75. <div class="soc-med-links-item-text">
  76. SourceCodester
  77. </div>
  78. </a>
  79. </div>
  80. </div>
  81. </div>
  82. </main>
  83. </body>
  84. </html>

Developing the CSS File

Next, we'll create the CSS file, which houses the styling scripts for the page element interface and design. Begin by generating a new CSS file and save it with the name styles.css. Remember, this file is linked and loaded within the HTML code file.

  1. @import url('https://fonts.googleapis.com/css2?family=Exo+2:ital,wght@0,100;0,200;0,300;0,400;0,500;1,100;1,200;1,300;1,400;1,500&display=swap');
  2.  
  3. :root{
  4. --bg-primary: #3876BF;
  5. --bg-secondary: #4D4C7D;
  6. --bg-red: #D80032;
  7. --bg-dark: #352F44;
  8. --bg-warn: #FBDA61;
  9. --bg-gradient: linear-gradient(45deg, #FBDA61 0%, #FF5ACD 100%);
  10. }
  11.  
  12. * {
  13. font-family: 'Exo 2', sans-serif;;
  14. }
  15. /* Page Interface Design */
  16. html, body{
  17. width: 100%;
  18. height: 100%;
  19. margin: unset;
  20. padding: unset;
  21. }
  22.  
  23. body{
  24. background-color: #0093E9;
  25. background-image: linear-gradient(160deg, #0093E9 0%, #80D0C7 100%);
  26. }
  27.  
  28. main{
  29. width: 100%;
  30. height: 100%;
  31. display: flex;
  32. flex-flow: column wrap;
  33. align-items: center;
  34. justify-content: center;
  35. }
  36. #wrapper{
  37. width: 100%;
  38. max-width: 500px;
  39. }
  40. /* Page Title */
  41. h2.title{
  42. font-weight: bold;
  43. color:#fff;
  44. letter-spacing: 0.3px;
  45. text-align: center;
  46. }
  47.  
  48. /* Social Media Links Styles */
  49.  
  50. /* Social Media Links or Button Wrapper */
  51. #soc-med-links{
  52. display: flex;
  53. flex-flow: row wrap;
  54. min-width: 100px;
  55. max-width: 100%;
  56. column-gap: 10px;
  57. justify-content: space-between;
  58. }
  59.  
  60. /* Social Media Link Item */
  61. #soc-med-links .soc-med-links-item {
  62. box-shadow: 0px 3px 3px #0000003a;
  63. background-color: #fff;
  64. border-radius: 2rem;
  65. transition: all .3s ease-in-out;
  66. }
  67.  
  68. /* Social Media Link Item anchor tag Element */
  69.  
  70. #soc-med-links .soc-med-links-item a{
  71. text-decoration: none !important;
  72. color:#352F44 !important;
  73. display: flex;
  74. align-items: center;
  75. justify-content: center;
  76. }
  77.  
  78. /* Social Media Link Item Icon/Logo Element */
  79. #soc-med-links .soc-med-links-item .soc-med-links-item-icon {
  80. height: 50px;
  81. width: 50px;
  82. display: flex;
  83. flex-direction: column;
  84. align-items: center;
  85. justify-content: center;
  86. border: 1px solid #e8e8e8;
  87. background-color: #fff;
  88. border-radius: 50% 50%;
  89. font-size: 2rem;
  90. }
  91.  
  92. /* Social Media Link Item Text Element */
  93. #soc-med-links .soc-med-links-item .soc-med-links-item-text {
  94. font-size: 14px;
  95. font-weight: 600;
  96. letter-spacing: .5px;
  97. overflow: hidden;
  98. width: 0;
  99. }
  100.  
  101. /* Social Media Link Icon when Hovered */
  102. #soc-med-links .soc-med-links-item:hover .soc-med-links-item-icon{
  103. position: relative;
  104. top: 1px;
  105. left: 1px;
  106. border:unset;
  107. }
  108.  
  109. /* Social Media Link when Hovered Colors */
  110. #soc-med-links .soc-med-links-item:hover .soc-med-links-item-icon.bg-primary{
  111. background-color: var(--bg-primary);
  112. color: #fff;
  113. }
  114. #soc-med-links .soc-med-links-item:hover .soc-med-links-item-icon.bg-secondary{
  115. background-color: var(--bg-secondary);
  116. color: #fff;
  117. }
  118. #soc-med-links .soc-med-links-item:hover .soc-med-links-item-icon.bg-dark{
  119. background-color: var(--bg-dark);
  120. color: #fff;
  121. }
  122. #soc-med-links .soc-med-links-item:hover .soc-med-links-item-icon.bg-red{
  123. background-color: var(--bg-red);
  124. color: #fff;
  125. }
  126. #soc-med-links .soc-med-links-item:hover .soc-med-links-item-icon.bg-gradient{
  127. background-color: var(--bg-warn);
  128. background-image: var(--bg-gradient);
  129. color: #fff;
  130. }
  131.  
  132. /* Adding animation when hovering */
  133. #soc-med-links .soc-med-links-item:hover .soc-med-links-item-text{
  134. animation: expandingAnimation .5s ease forwards;
  135. }
  136.  
  137. /* Expanding the Link Text Animation */
  138.  
  139. @keyframes expandingAnimation {
  140. 0%{
  141. width: 0;
  142. margin: 0px 0px;
  143. }
  144. 100%{
  145. width: auto;
  146. margin: 5px 10px;
  147. }
  148. }

For the outcome of the provided script, please consult the following images:

Social Media Links in Their Default State

Creating a Cool Social Medial Links for Websites using HTML and CSS

Social Media Links on Hover

Creating a Cool Social Medial Links for Websites using HTML and CSS

Creating a Cool Social Medial Links for Websites using HTML and CSS

And there you have it! I hope this tutorial on creating a Cool Hoverable Social Media Links/Buttons UI using HTML and CSS will be beneficial and prove valuable for your future website or web application projects. Additionally, a compressed source code file is available within this article for download. You can access it by clicking the download button located below this article's content.

Explore further on this website for more Free Source Codes, Tutorials, and Articles covering various programming languages.

Happy Coding =)

Add new comment