Home 〉 Other Tutorials 〉 Visual Studio Code Tutorials 〉How to Run HTML, CSS & JavaScript in Visual Studio Code | Step-by-Step
How to Run HTML, CSS & JavaScript in Visual Studio Code | Step-by-Step !
You now know how to write and run HTML, CSS, and JavaScript in Visual Studio Code. VS Code is fast, lightweight, and perfect for front-end developers. Using this setup with Live Server and basic files, you can start building real websites today!
Are you a beginner looking to build websites with HTML, CSS, and JavaScript? Wondering how to use Visual Studio Code (VS Code) to write and run your code? You’re in the right place. VS Code is one of the best code editors for front-end web development and is widely used by developers around the world.
In this beginner-friendly guide, you'll learn how to:
Once installed, open VS Code and you’re ready to start coding!
This will make VS Code your workspace for writing HTML, CSS, and JavaScript code.
Now you have the three main files needed for a basic website.
Open index.html and type this basic HTML structure:
<!DOCTYPE html>
<html>
<head>
<title>>My First Website</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Hello World</h1>
<button onclick="showMessage()">Click Me</button>
<script src="script.js"></script>
</body>
</html>
Open style.css and add this:
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}
button {
padding: 10px 20px;
font-size: 16px;
}
Open script.js and add this simple function:
function showMessage() {
alert("Button clicked! Welcome to my website.");
}
Your website will open in the browser, and any changes will auto-refresh.
No, you only need VS Code and a browser. For auto-refresh, install the Live Server extension.
Yes. You can build and test complete websites using HTML, CSS, and JavaScript directly inside VS Code.
Make sure your file names are correct and properly linked in the HTML file using <link> and <script> tags.