Creating a personal portfolio website is a great way to showcase your skills, projects, and experience. Whether you’re a developer, designer, or any other professional, a portfolio site can help you stand out. In this tutorial, we will build a simple, modern portfolio website using HTML, CSS, and JavaScript.
Project Overview
Features:
- A homepage with a brief introduction and a navigation menu.
- A “Projects” section to display your work.
- An “About” section with information about yourself.
- A “Contact” section with a contact form.
- Smooth scrolling for navigation.
Tools and Technologies Used
- HTML: For structuring the web pages.
- CSS: For styling the website.
- JavaScript: For adding interactivity and smooth scrolling.
Step 1: Setting Up the Project
Create a directory for your project and create the following files inside it:
index.html
– The HTML file for the structure of the portfolio.styles.css
– The CSS file for styling the website.script.js
– The JavaScript file for adding interactivity.
Step 2: Building the HTML Structure
Open the index.html
file and set up the basic structure for our portfolio website.
My Portfolio
Welcome to My Portfolio
Hi, I'm [Your Name]. A passionate developer.
My Projects
Project Title 1
Description of project 1.
Project Title 2
Description of project 2.
About Me
This is where you can add information about yourself, your skills, and your experience.
Contact Me
Step 3: Styling the Website with CSS
Next, let’s add some CSS to style our portfolio website. Open the styles.css
file and add the following styles:
/* styles.css */
/* Reset some default styles */
body, h1, h2, p, ul, li {
margin: 0;
padding: 0;
list-style: none;
}
body {
font-family: Arial, sans-serif;
line-height: 1.6;
background-color: #f4f4f4;
color: #333;
}
header {
background: #333;
color: #fff;
padding: 10px 0;
text-align: center;
position: sticky;
top: 0;
width: 100%;
z-index: 1000;
}
nav ul {
display: flex;
justify-content: center;
}
nav ul li {
margin: 0 15px;
}
nav ul li a {
color: #fff;
text-decoration: none;
font-weight: bold;
}
.section {
padding: 20px;
text-align: center;
margin-top: 50px;
}
#home {
background: #555;
color: white;
padding: 50px 0;
}
#projects {
background: #e2e2e2;
}
.projects-container {
display: flex;
justify-content: center;
flex-wrap: wrap;
}
.project {
background: #fff;
border: 1px solid #ddd;
padding: 15px;
margin: 10px;
width: 200px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
#about {
background: #f9f9f9;
}
#contact {
background: #ddd;
}
form {
max-width: 400px;
margin: 0 auto;
padding: 20px;
background: #fff;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
input, textarea {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
padding: 10px 20px;
border: none;
background: #333;
color: #fff;
cursor: pointer;
border-radius: 5px;
}
button:hover {
background: #555;
}
footer {
background: #333;
color: #fff;
text-align: center;
padding: 10px 0;
position: fixed;
bottom: 0;
width: 100%;
}
Step 4: Adding Interactivity with JavaScript
We will add smooth scrolling to our navigation menu using JavaScript. Open the script.js
file and add the following code:
// script.js
// Smooth scrolling for navigation links
document.querySelectorAll('nav ul li a').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
const targetElement = document.getElementById(targetId);
window.scrollTo({
top: targetElement.offsetTop,
behavior: 'smooth'
});
});
});
Explanation of the Code
- HTML Structure: We created a basic structure with a header, multiple sections (
home
,projects
,about
, andcontact
), and a footer. Each section has an ID that corresponds to the navigation links, enabling smooth scrolling. - CSS Styling: We used CSS to style the header, sections, buttons, and the footer, giving the website a clean and modern look. The
nav ul
uses Flexbox for horizontal alignment, and the.projects-container
uses Flexbox to align projects side-by-side. - JavaScript: We added an event listener to all navigation links to prevent the default action and enable smooth scrolling to the respective sections.
Step 5: Running the Portfolio Website
- Save all the files:
index.html
,styles.css
, andscript.js
. - Open the
index.html
file in your browser. - You should see a complete portfolio website with navigation, project display, an about section, and a contact form.
Conclusion
Congratulations! You’ve successfully built a simple portfolio website using HTML, CSS, and JavaScript. This project is a great starting point for creating a personal website to showcase your skills and projects. You can further enhance this site by:
- Adding a back-end to handle form submissions (e.g., using PHP or a serverless function).
- Implementing a responsive design to make it mobile-friendly.
- Adding more interactive features using JavaScript or integrating third-party libraries.
Happy coding, and good luck with your portfolio!