---
# System prepended metadata

title: Building Your First Web Page with HTML and Git

---

**Building Your First Web Page with HTML and Git**

### Introduction

Creating a basic web page is an exciting first step into the world of web development. HTML (Hypertext Markup Language) is the foundation for building any webpage, while Git is a version control system that helps developers manage changes to their code over time. In this article, we'll walk through how to create your first web page using HTML and Git, allowing you to not only build your page but also keep track of any changes you make using Git.

### What are HTML and Git?

**HTML** is the standard markup language used to create webpages. It structures content on the web by defining elements like headings, paragraphs, images, and links. HTML is easy to learn, and understanding it is essential for anyone interested in web development.

**Git** is a version control system that tracks changes to your codebase over time. It allows you to revert back to previous versions of your code, collaborate with other developers, and keep your project organized. Version control is crucial because it helps prevent mistakes and ensures that all changes can be traced back to their source.

### Why is Version Control Important?

Version control systems like Git allow you to track changes and keep a history of your project. If you make a mistake, you can always go back to a previous version. This is particularly useful when working on larger projects or collaborating with others, as it helps avoid confusion and conflicts in code. Git also enables collaboration by making it easy for multiple developers to work on the same project without overwriting each other's work.

### Setting Up the Project

To get started, we need to create a project folder and initialize a Git repository.

#### 1. Create a Project Folder

First, create a new folder on your computer where you will store your web page files. You can name this folder anything you like, such as "my-first-webpage."

For example:
```bash
mkdir my-first-webpage
cd my-first-webpage
```

#### 2. Initialize a Git Repository

Inside your project folder, open a terminal or command prompt and initialize a Git repository with the following command:
```bash
git init
```
This command will create a `.git` folder inside your project directory, allowing Git to track changes made to your files.

#### 3. Create Your First `index.html` File

Now it's time to create the first HTML file for your web page. In your project folder, create a file named `index.html`. This file will serve as the main file that browsers read to display your webpage.

```bash
touch index.html
```

### Writing the HTML Code

Now that we've set up our project, let's write some basic HTML code for our first web page. Open the `index.html` file in a text editor (e.g., Visual Studio Code, Sublime Text, or Notepad++) and start writing the code.

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My First Web Page</title>
</head>
<body>
  <h1>Welcome to My First Web Page</h1>
  <p>This is my first attempt at creating a webpage with HTML.</p>
  <a href="https://www.example.com">Click here to visit another page</a>
</body>
</html>
```

**Explanation of the code:**
- `<!DOCTYPE html>`: Defines the document as an HTML5 document.
- `<html>`: Starts the HTML document.
- `<head>`: Contains metadata like the title and character encoding.
- `<title>`: Sets the title of the webpage (appears in the browser tab).
- `<body>`: Contains the visible content of the webpage, such as headings, paragraphs, and links.
- `<h1>`: Defines a large heading.
- `<p>`: Defines a paragraph of text.
- `<a>`: Defines a link to another page.

### Using Git for Version Control

Now that we've written some HTML code, it's time to use Git to track changes.

#### 1. Staging and Committing Changes

Whenever you make changes to your code, you need to "stage" those changes with the `git add` command and then commit them using `git commit`. Staging means telling Git which files you want to include in the next commit, while committing saves a snapshot of the changes.

```bash
git add index.html
git commit -m "Initial commit: Created index.html with basic structure"
```

**Explanation of the commands:**
- `git add index.html`: Stages the changes made to the `index.html` file.
- `git commit -m "Initial commit..."`: Commits the staged changes with a meaningful message.

#### 2. Writing Meaningful Commit Messages

When writing commit messages, it's important to describe the changes you made. This helps you understand the history of your project as it grows. A good commit message is clear and concise. For example:
- "Add heading and paragraph to index.html"
- "Fix typo in paragraph text"

### Pushing Code to GitHub (Optional for Advanced Students)

If you'd like to share your project or collaborate with others, you can upload your code to GitHub, a platform for hosting Git repositories.

#### 1. Create a GitHub Repository

First, go to [GitHub](https://github.com/) and create a new repository. Give it a name like "my-first-webpage."

#### 2. Connect the Local Repository to GitHub

Once you've created the repository, GitHub will provide you with the necessary commands to link your local Git repository to GitHub. Run the following commands:

```bash
git remote add origin https://github.com/yourusername/my-first-webpage.git
git branch -M main
git push -u origin main
```

#### 3. Pushing Changes to GitHub

After setting up the remote repository, you can push your local changes to GitHub using the following command:

```bash
git push
```

This will upload your local code to the GitHub repository, making it accessible from anywhere and enabling collaboration.

### Conclusion

Congratulations! You've just created your first web page using HTML and learned how to track changes with Git. By using Git for version control, you'll be able to keep your project organized and ensure you can always roll back to previous versions of your code.

Remember, practice is key when learning web development. Experiment with different HTML tags, add more content to your page, and explore more advanced features of Git like branching and merging. Happy coding!