Run HTML Code in GitHub Codespaces: A Step-by-Step Guide

Ann Jul 09, 2026

Embarking on a coding journey with GitHub Codespaces? You're in for a treat! GitHub Codespaces is an innovative cloud-based development environment that allows you to code directly in your browser or via a local IDE. One of the most compelling features of Codespaces is its ability to run HTML code seamlessly. Let's dive into a step-by-step guide on how to run HTML code in GitHub Codespaces.

login form html css
login form html css

Before we begin, ensure you have a GitHub account and have set up your Codespaces. If you haven't, GitHub provides a comprehensive guide on getting started with Codespaces.

an image of a web page with the text'html input types'on it
an image of a web page with the text'html input types'on it

Setting Up Your HTML File

First, let's create a new HTML file in your Codespaces project. You can do this by right-clicking in the file explorer and selecting 'New File'. Name your file 'index.html'.

html and css login form
html and css login form

Now, let's add some basic HTML content to your 'index.html' file. Open the file and paste the following code:

```html My First HTML Page

Hello, World!

GitHub Codespaces
GitHub Codespaces

This is my first HTML page.

```

Running Your HTML Code

Now that you have your HTML file set up, it's time to run your code. In your Codespaces, you'll notice a terminal at the bottom of the screen. This is where we'll run our command.

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

To run your HTML code, type the following command in the terminal and press enter:

```bash code . ```

Viewing Your HTML Page

After running the command, your default browser should open, displaying your HTML page. If it doesn't, you can manually open your browser and navigate to 'http://localhost:8080'. You should see your 'Hello, World!' message and the text 'This is my first HTML page'.

a screen shot of a web page with the words'html input types '
a screen shot of a web page with the words'html input types '

Congratulations! You've successfully run HTML code in GitHub Codespaces.

Exploring More Features

Basic Of HTML | Web Development | Programming
Basic Of HTML | Web Development | Programming
a computer screen with a pink flower on it
a computer screen with a pink flower on it
Why you should use Ctrl Shift L in VS Code | HTML and CSS Tutorial
Why you should use Ctrl Shift L in VS Code | HTML and CSS Tutorial
Basics of HTML
Basics of HTML
the github chat sheet is displayed in this screenshote screen graber
the github chat sheet is displayed in this screenshote screen graber
two screens showing different types of programming
two screens showing different types of programming
an image of a blue screen with the words html structure in white letters on it
an image of a blue screen with the words html structure in white letters on it
a table that has some type of text in red and black on the bottom right hand corner
a table that has some type of text in red and black on the bottom right hand corner
the different types of text are displayed on this page, and it appears to be in multiple
the different types of text are displayed on this page, and it appears to be in multiple
HTML Cheat Sheet 📄✨ Quick Guide for Beginners
HTML Cheat Sheet 📄✨ Quick Guide for Beginners
html css download button animation
html css download button animation
an image of a computer screen with the text all filters in css
an image of a computer screen with the text all filters in css
Blinking Text Using HTML and CSS
Blinking Text Using HTML and CSS
an image with the text, code in your browser without any setup on it
an image with the text, code in your browser without any setup on it
an image of the back side of a computer screen with text that reads, add css to html
an image of the back side of a computer screen with text that reads, add css to html
tg: webguild
tg: webguild
an image of a computer screen with some type of programming program on it's side
an image of a computer screen with some type of programming program on it's side
the different types of html tags are shown in this screenshote screen graber
the different types of html tags are shown in this screenshote screen graber
Modern HTML Forms
Modern HTML Forms
What Is GitHub? Ultimate Guide on How to Use GitHub in 2023
What Is GitHub? Ultimate Guide on How to Use GitHub in 2023

GitHub Codespaces offers a wide range of features to enhance your coding experience. You can explore these features by checking out the GitHub documentation or by experimenting with different commands in the terminal.

Using Prettier for Code Formatting

Prettier is a popular code formatter that can help maintain a consistent coding style. To use Prettier in your Codespaces, you'll first need to install it. In the terminal, type the following command and press enter:

```bash npm install --save-dev --save-exact prettier ```

Once installed, you can format your code by running:

```bash npx prettier --write . ```

Using Live Server for Real-Time Preview

Live Server is a plugin that allows you to preview your HTML changes in real-time. To use Live Server, you'll need to install it as a VS Code extension. Once installed, right-click on your 'index.html' file and select 'Open with Live Server'.

Your browser should open, displaying your HTML page. Any changes you make to your code will be reflected instantly in the browser.

And there you have it! You've successfully run HTML code in GitHub Codespaces and explored some of its powerful features. Happy coding!