How to Add GitHub Icon in HTML

Ann Jul 09, 2026

Adding a GitHub icon to your HTML can help visitors quickly recognize your project's presence on the platform and encourage them to explore further. Here's a step-by-step guide on how to achieve this.

Github Profile
Github Profile

Before we dive into the process, ensure you have a basic understanding of HTML and how to structure your web pages. If you're new to HTML, don't worry – we'll keep the explanations simple and straightforward.

GIT  HUB icon | github logo png
GIT HUB icon | github logo png

Using an Image Element

The most common way to add a GitHub icon is by using the <img> tag to display an image. First, you need to find or create a GitHub icon that suits your project's style.

the logo for github on a computer screen
the logo for github on a computer screen

For this example, let's use the official GitHub icon: . This icon is small, recognizable, and hosted on GitHub's CDN, ensuring fast loading times.

Directly Linking the Icon

4 Ways To Add Icons In HTML & CSS
4 Ways To Add Icons In HTML & CSS

To add the icon to your HTML, use the following code snippet:

<img src="https://github.com/favicon.ico" alt="GitHub Icon">

The src attribute specifies the URL of the icon, while the alt attribute provides alternative text for screen readers and improves accessibility.

GitHub Computer Icons Directory PNG
GitHub Computer Icons Directory PNG

Styling the Icon

You can style the icon using CSS to match your website's design. For instance, you can change the icon's size, add padding, or adjust its color:

<style> img.github-icon { width: 32px; height: 32px; padding: 4px; color: #fff; background-color: #24292e; border-radius: 50%; } </style>

a cat's head is shown in a blue circle
a cat's head is shown in a blue circle

In this example, the icon is styled to resemble a GitHub button. You can adjust the CSS as needed to fit your project's theme.

Using an SVG Icon

a black and white silhouette of a cat
a black and white silhouette of a cat
Github Logo
Github Logo
How to Use GitHub: Essential Tips and Tricks for Developers
How to Use GitHub: Essential Tips and Tricks for Developers
the gitt hub logo with a cat on it's head and an oval background
the gitt hub logo with a cat on it's head and an oval background
...
...
github
github
github
github
GitHub - Collaborez efficacement sur vos projets de code en équipe
GitHub - Collaborez efficacement sur vos projets de code en équipe
Modern GitHub Profile UI
Modern GitHub Profile UI
Download GitHub Logo, Git Hub Icon With Text On White and Black Background
Download GitHub Logo, Git Hub Icon With Text On White and Black Background
the logo for github social coding, which is designed to look like a cat
the logo for github social coding, which is designed to look like a cat
the logo for gitthub is shown with a black cat on it's head
the logo for gitthub is shown with a black cat on it's head
Alphabet Art Coloring Pages github Campus Expert Program, apply Now - PrimaNYC.com
Alphabet Art Coloring Pages github Campus Expert Program, apply Now - PrimaNYC.com
a computer screen with a pink flower on it
a computer screen with a pink flower on it
Introducing Github copilot AI tool of the week
Introducing Github copilot AI tool of the week
How to Create Github Account and Repository Step by Step
How to Create Github Account and Repository Step by Step
the github chat sheet is displayed in this screenshote screen graber
the github chat sheet is displayed in this screenshote screen graber
Embedding Images in HTML using <img>
Embedding Images in HTML using <img>
the logo for github pages is shown on a blue background with white lettering
the logo for github pages is shown on a blue background with white lettering
a black and white image of a cat in front of a screen with code numbers
a black and white image of a cat in front of a screen with code numbers

Scalable Vector Graphics (SVG) offer better scalability and control over the icon's appearance compared to raster images. Here's how to add a GitHub SVG icon to your HTML:

Embedding the SVG Code

First, you need to obtain the SVG code for the GitHub icon. You can find it in the official GitHub repository: . Copy the contents of the file.

Next, embed the SVG code in your HTML using a <div> element with the appropriate class or ID for styling:

<div class="github-icon"> <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"> <path d="M16 3.13a12.89 12.89 0 0 1 10.52 3.77 12.89 12.89 0 0 1-3.76 10.52l-9.17 9.17zm5.38 9.17V16h-2.75V9.17h2.75z" fill="white"/> </svg> </div>

Styling the SVG Icon

Now, you can style the SVG icon using CSS. For example, you can add a background color and adjust the size:

<style> .github-icon { background-color: #24292e; width: 40px; height: 40px; display: inline-block; border-radius: 50%; } </style>

With this approach, you have more control over the icon's appearance and can easily adjust its size without losing quality.

Incorporating a GitHub icon into your HTML project is a simple yet effective way to connect your project with the platform. By following the steps outlined above, you can choose the method that best fits your project's needs and style. Happy coding!