Complete step-by-step guide to build your first website from scratch for beginners in web development.
Building your first website is an exciting milestone. Whether you want to showcase your portfolio, start a blog, launch a business, or simply learn a valuable skill, creating a website from scratch is more accessible than ever.
The best part? You don't need to be a tech genius or spend lakhs on developers. With the right guidance, you can build a professional-looking website in a weekend.
This comprehensive guide will walk you through every step—from understanding the basics to deploying your site live on the internet.
For Students:
For Professionals:
For Entrepreneurs:
| Skill | Value |
|---|---|
| HTML | Structure any web content |
| CSS | Design beautiful interfaces |
| Problem-solving | Debug and fix issues |
| Project management | Complete a full project |
| Deployment | Put things live on the internet |
When you visit a website:
Your Browser → Request → Server → Response → Displayed Website
| Technology | Purpose | Analogy |
|---|---|---|
| HTML | Structure and content | The skeleton/bones |
| CSS | Styling and appearance | The skin and clothes |
| JavaScript | Interactivity and behavior | The muscles and brain |
For your first website, you'll focus on HTML and CSS. JavaScript can come later.
Software (All Free):
No Need For:
Why VS Code?
In VS Code, click the Extensions icon (four squares) and install:
| Extension | Purpose |
|---|---|
| Live Server | Preview changes instantly |
| Prettier | Auto-format your code |
| HTML CSS Support | Better code suggestions |
| Auto Rename Tag | Rename HTML tags easily |
my-first-websitemy-first-website folderYou're now ready to start coding!
HTML uses tags to define content. Most tags have an opening and closing part:
<tagname>Content goes here</tagname>
Examples:
<h1>This is a heading</h1>
<p>This is a paragraph</p>
<a href="https://google.com">This is a link</a>
| Tag | Purpose | Example |
|---|---|---|
<html> | Root of HTML document | Wraps everything |
<head> | Metadata and links | Title, CSS links |
<body> | Visible content | Everything users see |
<h1> to <h6> | Headings | <h1>Main Title</h1> |
<p> | Paragraph | <p>Some text...</p> |
<a> | Link | <a href="url">Click</a> |
<img> | Image | <img src="photo.jpg"> |
<div> | Container/section | <div>...</div> |
<ul>, <li> | Unordered list | Bullet points |
<ol>, <li> | Ordered list | Numbered list |
index.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 Website</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>Welcome to my first website. I built this myself!</p>
</body>
</html>
<!DOCTYPE html>
<!-- Tells browser this is HTML5 -->
<html lang="en">
<!-- Root element, language is English -->
<head>
<!-- Invisible metadata section -->
<meta charset="UTF-8" />
<!-- Character encoding -->
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<!-- Mobile responsive -->
<title>My First Website</title>
<!-- Browser tab title -->
</head>
<body>
<!-- Visible content starts here -->
<!-- Your content goes here -->
</body>
</html>
We'll create a simple one-page portfolio with:
Replace your index.html content with:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<title>Rahul Sharma - Portfolio</title>
<link
rel="stylesheet"
href="styles.css"
/>
</head>
<body>
<!-- Header with Navigation -->
<header>
<nav>
<div class="logo">Rahul Sharma</div>
<ul class="nav-links">
<li><a href="#about">About</a></li>
<li><a href="#skills">Skills</a></li>
<li><a href="#projects">Projects</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<!-- Hero Section -->
<section id="hero">
<h1>Hi, I'm Rahul Sharma</h1>
<p>Aspiring Software Developer | B.Tech CSE Student</p>
<a
href="#contact"
class="btn"
>Get in Touch</a
>
</section>
<!-- About Section -->
<section id="about">
<h2>About Me</h2>
<p>
I'm a passionate computer science student with a love for building things that live on the
internet. I'm currently learning web development and working on exciting projects.
</p>
<p>
When I'm not coding, you'll find me reading tech blogs, playing chess, or exploring new
technologies.
</p>
</section>
<!-- Skills Section -->
<section id="skills">
<h2>My Skills</h2>
<div class="skills-container">
<div class="skill-card">
<h3>HTML/CSS</h3>
<p>Building responsive and beautiful web pages</p>
</div>
<div class="skill-card">
<h3>JavaScript</h3>
<p>Adding interactivity to websites</p>
</div>
<div class="skill-card">
<h3>Python</h3>
<p>Problem-solving and automation</p>
</div>
<div class="skill-card">
<h3>Git</h3>
<p>Version control and collaboration</p>
</div>
</div>
</section>
<!-- Projects Section -->
<section id="projects">
<h2>My Projects</h2>
<div class="projects-container">
<div class="project-card">
<h3>Todo App</h3>
<p>A simple task management application built with HTML, CSS, and JavaScript.</p>
<a
href="#"
class="btn-small"
>View Project</a
>
</div>
<div class="project-card">
<h3>Weather App</h3>
<p>Real-time weather information using a public API.</p>
<a
href="#"
class="btn-small"
>View Project</a
>
</div>
<div class="project-card">
<h3>Calculator</h3>
<p>A functional calculator with a clean interface.</p>
<a
href="#"
class="btn-small"
>View Project</a
>
</div>
</div>
</section>
<!-- Contact Section -->
<section id="contact">
<h2>Get in Touch</h2>
<p>I'm always open to discussing new projects and opportunities.</p>
<div class="contact-links">
<a href="mailto:[email protected]">Email Me</a>
<a
href="https://linkedin.com/in/rahul"
target="_blank"
>LinkedIn</a
>
<a
href="https://github.com/rahul"
target="_blank"
>GitHub</a
>
</div>
</section>
<!-- Footer -->
<footer>
<p>© 2026 Rahul Sharma. Built with ❤️</p>
</footer>
</body>
</html>
Save the file. You now have the structure, but it won't look pretty yet—that's where CSS comes in!
CSS (Cascading Style Sheets) controls how HTML elements look:
selector {
property: value;
}
Example:
h1 {
color: blue;
font-size: 36px;
}
This makes all <h1> elements blue and 36 pixels in size.
| Selector | Targets | Example |
|---|---|---|
| Element | All elements of that type | p { } |
| Class | Elements with that class | .card { } |
| ID | Element with that ID | #header { } |
| Descendant | Nested elements | nav a { } |
styles.css in the same folder/* Reset and Base Styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: #333;
}
/* Navigation */
header {
background: #2c3e50;
padding: 1rem 2rem;
position: fixed;
width: 100%;
top: 0;
z-index: 1000;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
max-width: 1200px;
margin: 0 auto;
}
.logo {
color: #fff;
font-size: 1.5rem;
font-weight: bold;
}
.nav-links {
display: flex;
list-style: none;
gap: 2rem;
}
.nav-links a {
color: #fff;
text-decoration: none;
transition: color 0.3s;
}
.nav-links a:hover {
color: #3498db;
}
/* Hero Section */
#hero {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #fff;
text-align: center;
padding: 150px 20px 100px;
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#hero h1 {
font-size: 3rem;
margin-bottom: 1rem;
}
#hero p {
font-size: 1.3rem;
margin-bottom: 2rem;
opacity: 0.9;
}
/* Buttons */
.btn {
background: #fff;
color: #667eea;
padding: 12px 30px;
border-radius: 25px;
text-decoration: none;
font-weight: bold;
transition:
transform 0.3s,
box-shadow 0.3s;
}
.btn:hover {
transform: translateY(-3px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}
.btn-small {
background: #3498db;
color: #fff;
padding: 8px 20px;
border-radius: 20px;
text-decoration: none;
font-size: 0.9rem;
transition: background 0.3s;
}
.btn-small:hover {
background: #2980b9;
}
/* Sections */
section {
padding: 80px 20px;
max-width: 1200px;
margin: 0 auto;
}
section h2 {
text-align: center;
font-size: 2.5rem;
margin-bottom: 2rem;
color: #2c3e50;
}
/* About Section */
#about {
background: #f8f9fa;
}
#about p {
max-width: 800px;
margin: 0 auto 1rem;
text-align: center;
font-size: 1.1rem;
}
/* Skills Section */
.skills-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
margin-top: 2rem;
}
.skill-card {
background: #fff;
padding: 30px;
border-radius: 10px;
text-align: center;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
transition: transform 0.3s;
}
.skill-card:hover {
transform: translateY(-5px);
}
.skill-card h3 {
color: #667eea;
margin-bottom: 10px;
}
/* Projects Section */
#projects {
background: #f8f9fa;
}
.projects-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 25px;
margin-top: 2rem;
}
.project-card {
background: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
.project-card h3 {
color: #2c3e50;
margin-bottom: 15px;
}
.project-card p {
margin-bottom: 20px;
color: #666;
}
/* Contact Section */
#contact {
text-align: center;
}
.contact-links {
display: flex;
justify-content: center;
gap: 20px;
margin-top: 2rem;
}
.contact-links a {
background: #2c3e50;
color: #fff;
padding: 12px 25px;
border-radius: 25px;
text-decoration: none;
transition: background 0.3s;
}
.contact-links a:hover {
background: #3498db;
}
/* Footer */
footer {
background: #2c3e50;
color: #fff;
text-align: center;
padding: 25px;
}
/* Responsive Design */
@media (max-width: 768px) {
.nav-links {
display: none;
}
#hero h1 {
font-size: 2rem;
}
#hero p {
font-size: 1rem;
}
section h2 {
font-size: 1.8rem;
}
}
Save the file and refresh your browser. Your website should now look professional!
Flexbox makes it easy to align and distribute elements:
.container {
display: flex;
justify-content: space-between; /* Horizontal alignment */
align-items: center; /* Vertical alignment */
gap: 20px; /* Space between items */
}
Common justify-content values:
flex-start - Align to startflex-end - Align to endcenter - Center itemsspace-between - Equal space betweenspace-around - Equal space aroundGrid is perfect for card layouts:
.grid-container {
display: grid;
grid-template-columns: repeat(3, 1fr); /* 3 equal columns */
gap: 20px;
}
/* Responsive: auto-fit adjusts based on screen size */
.responsive-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
}
Add smooth animations:
.card {
transition:
transform 0.3s ease,
box-shadow 0.3s ease;
}
.card:hover {
transform: translateY(-10px);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}
Create beautiful backgrounds:
.gradient-bg {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
This tag (already in your HTML) makes mobile responsive design possible:
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
Change styles based on screen size:
/* Tablet and below */
@media (max-width: 768px) {
.nav-links {
display: none;
}
.skills-container {
grid-template-columns: 1fr;
}
}
/* Mobile phones */
@media (max-width: 480px) {
#hero h1 {
font-size: 1.5rem;
}
section {
padding: 40px 15px;
}
}
Write CSS for mobile first, then add complexity for larger screens:
/* Base styles (mobile) */
.container {
flex-direction: column;
}
/* Larger screens */
@media (min-width: 768px) {
.container {
flex-direction: row;
}
}
<img
src="profile-photo.jpg"
alt="Rahul Sharma profile photo"
/>
Best Practices:
alt text for accessibility| Resource | Type | License |
|---|---|---|
| Unsplash | Photos | Free |
| Pexels | Photos | Free |
| Icons8 | Icons | Free with attribution |
| Font Awesome | Icons | Free tier available |
Use Font Awesome icons:
<!-- Add this in your <head> section -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
/>
<!-- Use icons in your HTML -->
<i class="fas fa-envelope"></i> Email <i class="fab fa-linkedin"></i> LinkedIn
<i class="fab fa-github"></i> GitHub
| Platform | Best For | Difficulty |
|---|---|---|
| GitHub Pages | Portfolio sites | Easy |
| Netlify | Any static site | Easy |
| Vercel | Modern web apps | Easy |
| Cloudflare Pages | Fast global delivery | Easy |
Step 1: Create a GitHub Account
Step 2: Create a New Repository
yourusername.github.io (replace with your username)Step 3: Upload Your Files
index.html, styles.css, and any imagesStep 4: Access Your Live Site
https://yourusername.github.ioPopular Registrars:
For GitHub Pages:
CNAME with your domain nameFor Netlify:
<!-- Wrong -->
<img src="C:\Users\Rahul\photos\me.jpg" />
<!-- Correct (relative path) -->
<img src="images/me.jpg" />
<!-- Wrong -->
<p>First paragraph</p>
<p>
Second paragraph
<!-- Correct -->
</p>
<p>First paragraph</p>
<p>Second paragraph</p>
<!-- Avoid (hard to maintain) -->
<p style="color: blue; font-size: 16px; margin: 10px;">Text</p>
<!-- Better (use CSS classes) -->
<p class="highlight-text">Text</p>
Always test your site on:
<header>, <nav>, <main>, <footer>)Add interactivity to your website:
// Example: Change text on button click
document.querySelector('.btn').addEventListener('click', function () {
alert('Button clicked!');
});
Make development faster:
| Project | Skills Practiced |
|---|---|
| Landing page for a product | Design, conversion |
| Restaurant website | Multi-page, menus |
| Blog template | Content layout |
| Web app clone | Complex layouts |
| Resource | Type | Best For |
|---|---|---|
| freeCodeCamp | Interactive | Comprehensive curriculum |
| The Odin Project | Course | Full web development |
| MDN Web Docs | Reference | Deep understanding |
| CSS-Tricks | Articles | CSS techniques |
| Kevin Powell (YouTube) | Video | CSS mastery |
You can use builders like Wix or Squarespace, but learning HTML/CSS gives you more control, is a valuable skill, and costs nothing. For portfolios and simple sites, knowing code is a significant advantage.
A simple portfolio can be built in a weekend (1-2 days). More complex sites take longer. With practice, you'll get faster.
No. HTML and CSS are sufficient for informational websites. JavaScript adds interactivity but isn't required for your first site.
Yes. Web developers are in high demand with salaries ranging from ₹4-25 LPA in India. The skills are transferable across industries.
Frontend is what users see (HTML, CSS, JavaScript). Backend is server-side logic and databases. As a beginner, start with frontend.
Yes. GitHub Pages, Netlify, and Vercel offer free hosting for static websites. You only pay if you want a custom domain.
Ready to advance your web development skills? Explore more tutorials and career guidance on Sproutern for comprehensive learning resources.
Our team of career experts, industry professionals, and former recruiters brings decades of combined experience in helping students and freshers launch successful careers.
Get 50+ real interview questions from top MNCs, ATS-optimized resume templates, and a step-by-step placement checklist — delivered to your inbox.
🔒 No spam. We respect your privacy.
If you found this article helpful, please cite it as: