Master HTML & CSS Websites on GitHub

Ann Jul 09, 2026

Embarking on your web development journey? You've likely encountered HTML and CSS, the backbone of web design. But where do you store and share your projects? Enter GitHub, the world's leading platform for version control and collaboration. Let's explore how to create, style, and host your HTML and CSS websites on GitHub.

Tips for css style Animation
Tips for css style Animation

Before we dive in, ensure you have a GitHub account and understand the basics of Git. If not, fear not! GitHub offers excellent documentation and tutorials to get you started.

login form html css
login form html css

Setting Up Your HTML and CSS Project

First, let's create a new repository (repo) on GitHub for your project. Log in to your GitHub account, click the '+' icon in the top-right corner, and select 'New repository'. Name it something descriptive, like 'my-website', and initialize it with a README.md file.

Host Websites Free with GitHub Pages 🚀💻
Host Websites Free with GitHub Pages 🚀💻

Now, let's set up your project locally. Create a new folder on your computer, navigate into it, and initialize a new Git repository using the command 'git init'. Inside this folder, create two files: 'index.html' and 'styles.css'.

Structuring Your HTML

css grid tool layout
css grid tool layout

Open 'index.html' and write your basic HTML structure. A simple one might look like this:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Website</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <h1>Welcome to My Website!</h1>
</body>
</html>

Notice the link to 'styles.css' in the head? This is where we'll apply our styling.

Styling with CSS

GitHub Readme Idea - Minimalism Black & White
GitHub Readme Idea - Minimalism Black & White

Open 'styles.css' and add some basic styling:

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 2rem;
  background-color: #f0f0f0;
}

h1 {
  color: #333;
}

Here, we've set the body's font, margin, padding, and background color, and changed the color of the h1 heading.

Connecting Your Local Project to GitHub

an image of a web page with cupcakes on it and the words website cupcake
an image of a web page with cupcakes on it and the words website cupcake

Now, let's connect your local project to your GitHub repository. First, add your files to Git using the commands 'git add .', 'git commit -m "Initial commit"', and 'git remote add origin https://github.com/yourusername/my-website.git'.

Finally, push your changes to GitHub with 'git push -u origin main'.

a web page with an image of two people and one is giving the thumbs up
a web page with an image of two people and one is giving the thumbs up
HTML input types
HTML input types
#CSS Animations Tips and Tricks
#CSS Animations Tips and Tricks
Top 5 HTML CSS Projects for Beginners
Top 5 HTML CSS Projects for Beginners
18 Exciting HTML and CSS Project Ideas with source code to Level Up Your Web Development Skills
18 Exciting HTML and CSS Project Ideas with source code to Level Up Your Web Development Skills
GitHub Dark Readme - Aesthetic
GitHub Dark Readme - Aesthetic
an image of a web page with the words hi, i'm divyansh chaudhary
an image of a web page with the words hi, i'm divyansh chaudhary
10 CSS Tricks Every Beginner Should Know
10 CSS Tricks Every Beginner Should Know
tg: webguild
tg: webguild
Github Profile 2
Github Profile 2
Master Css Using These Websites..
Master Css Using These Websites..
web development design website
web development design website
Design Elements in HTML & CSS
Design Elements in HTML & CSS
Github Profile
Github Profile
CSS Notes for Beginners (Easy + Quick Guide) 🎨
CSS Notes for Beginners (Easy + Quick Guide) 🎨
Html Cheet Sheet
Html Cheet Sheet
How to Center Anything in CSS (5 Ways)
How to Center Anything in CSS (5 Ways)
html and css login form
html and css login form
𝙃𝙏𝙈𝙇 𝙏𝙖𝙜𝙨 𝙘𝙝𝙚𝙖𝙩 𝙨𝙝𝙚𝙚𝙩
𝙃𝙏𝙈𝙇 𝙏𝙖𝙜𝙨 𝙘𝙝𝙚𝙖𝙩 𝙨𝙝𝙚𝙚𝙩
Top GitHub Open Source Projects for Web Development 🌐✨
Top GitHub Open Source Projects for Web Development 🌐✨

Publishing Your Website on GitHub

GitHub provides a simple way to host your static websites. In your repository's settings, scroll down to the 'Pages' section. Under 'Source', select 'main' (or 'master', depending on your default branch name), and click 'Save'. Your website will now be live at 'https://yourusername.github.io/my-website'.

To update your website, simply make changes locally, push to GitHub, and GitHub Pages will update automatically.

And there you have it! You've created, styled, and hosted your HTML and CSS website on GitHub. Happy coding, and remember to keep learning and experimenting to improve your skills.