The best way to learn HTML and CSS is to build something real. In this project you will create a personal portfolio website: a single page with a sticky navigation bar, a hero section, a responsive grid of project cards, an about section and an accessible contact form. It uses almost every topic from this course, and when you finish you will have a page you can publish and show to employers.
In this project you will practise
- Semantic page structure: header, nav, main, section, article, footer
- Design tokens with CSS variables
- Flexbox navigation and a responsive Grid of cards
- Sticky positioning, gradients, shadows and transitions
- Fluid type with
clamp(), a media query and an accessible form
The Finished Page
Result
Scroll inside the frame to see every section, and hover over the button and cards. Resize your browser window to watch the cards reflow.
The Complete Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Nadia Rahman | Web Developer</title>
<meta name="description" content="Portfolio of Nadia Rahman, a junior web developer from Dhaka.">
<style>
:root { --brand: #00695c; --bg: #ffffff; --text: #263238; --muted: #607d8b; --card: #f5f7f8; --r: 10px; }
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; color: var(--text); background: var(--bg); line-height: 1.6; }
a { color: var(--brand); }
.container { max-width: 900px; margin: 0 auto; padding: 0 16px; }
header { position: sticky; top: 0; background: var(--bg); box-shadow: 0 1px 4px rgba(0,0,0,.08); z-index: 5; }
nav { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; }
nav ul { list-style: none; display: flex; gap: 16px; margin: 0; padding: 0; }
nav a { text-decoration: none; font-weight: 600; }
nav a:hover, nav a:focus-visible { text-decoration: underline; }
.hero { padding: 40px 0 24px; background: linear-gradient(135deg, #e0f2f1, #ffffff); }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.6rem); margin: 0; }
.hero p { color: var(--muted); max-width: 520px; }
.btn { display: inline-block; background: var(--brand); color: #fff; padding: 10px 18px;
border-radius: var(--r); text-decoration: none; transition: transform .2s, box-shadow .2s; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,105,92,.3); }
section { padding: 24px 0; }
h2 { border-left: 4px solid var(--brand); padding-left: 10px; }
.projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.project { background: var(--card); border-radius: var(--r); padding: 14px; transition: box-shadow .2s; }
.project:hover { box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.project h3 { margin-top: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; list-style: none; }
.tags li { background: #b2dfdb; border-radius: 12px; padding: 0 10px; font-size: 13px; }
form { display: grid; gap: 8px; max-width: 420px; }
input, textarea { font: inherit; padding: 8px; border: 1px solid #b0bec5; border-radius: 6px; }
footer { text-align: center; color: var(--muted); padding: 20px 0; font-size: 14px; }
@media (max-width: 520px) { nav { flex-direction: column; gap: 6px; } }
</style>
</head>
<body>
<header>
<nav class="container" aria-label="Main">
<strong>Nadia Rahman</strong>
<ul><li><a href="#projects">Projects</a></li><li><a href="#about">About</a></li><li><a href="#contact">Contact</a></li></ul>
</nav>
</header>
<main>
<div class="hero">
<div class="container">
<h1>Hi, I build friendly websites.</h1>
<p>Junior web developer from Dhaka. I enjoy turning designs into fast, accessible pages.</p>
<a class="btn" href="#projects">See my work</a>
</div>
</div>
<section id="projects" class="container">
<h2>Projects</h2>
<div class="projects">
<article class="project"><h3>Quiz App</h3><p>A timed quiz with score tracking.</p>
<ul class="tags"><li>HTML</li><li>CSS</li><li>JavaScript</li></ul></article>
<article class="project"><h3>Library Catalogue</h3><p>Search and filter 500 books.</p>
<ul class="tags"><li>Python</li><li>SQL</li></ul></article>
<article class="project"><h3>Restaurant Landing Page</h3><p>Responsive menu and booking form.</p>
<ul class="tags"><li>Flexbox</li><li>Grid</li></ul></article>
</div>
</section>
<section id="about" class="container">
<h2>About</h2>
<p>I study Computer Science and practise with small projects every week. I care about clean code, good contrast and keyboard-friendly pages.</p>
</section>
<section id="contact" class="container">
<h2>Contact</h2>
<form action="#" method="post">
<label for="c-name">Name</label><input id="c-name" name="name" autocomplete="name" required>
<label for="c-email">Email</label><input id="c-email" name="email" type="email" autocomplete="email" required>
<label for="c-msg">Message</label><textarea id="c-msg" name="message" rows="3" required></textarea>
<button class="btn" type="submit">Send</button>
</form>
</section>
</main>
<footer>© 2026 Nadia Rahman</footer>
</body>
</html>
How It Is Built
- Head. The viewport tag, a specific
<title>and a meta description follow the advice in Meta Tags and SEO. - Design tokens. Colours and the corner radius live in
:rootvariables (see CSS Variables). Change--brandonce and the whole site’s accent colour changes. - Box sizing.
* { box-sizing: border-box; }makes padding count inside widths, avoiding many layout surprises (see the box model). - Container.
.containerlimits content to 900px and centres it withmargin: 0 auto, with side padding for phones. - Navigation. The header is
position: stickyso it stays visible (see Positioning), and Flexbox withjustify-content: space-betweenputs the name on the left and links on the right. Below 520px a media query stacks them. - Hero. A soft gradient background, a heading sized with
clamp()and a call-to-action button that lifts on hover with a transition. - Projects.
repeat(auto-fit, minmax(220px, 1fr))gives one, two or three columns depending on the space, with no breakpoints. Each project is an<article>with a list of technology tags. - Accessibility. Real links and buttons, a labelled navigation landmark, visible focus styles,
<label for>on every field andautocompletehints (see Accessibility Basics). - In-page links.
href="#projects"jumps to the element withid="projects". Addinghtml { scroll-behavior: smooth; }would animate the jump.
Publishing Your Portfolio
| Option | Cost | How |
|---|---|---|
| GitHub Pages | Free | Push index.html to a repository and enable Pages in its settings |
| Netlify or Cloudflare Pages | Free tier | Drag and drop the folder, or connect a GitHub repository |
| Your own domain | Yearly domain fee | Point the domain’s DNS to one of the hosts above |
The contact form needs a back end to actually send messages. Services such as Formspree accept the form’s action URL and email the submissions to you, or you can process it yourself once you learn a server language.
Ideas to Extend the Project
- Add a dark theme with
prefers-color-schemeand variables. - Add project screenshots with
srcsetandloading="lazy"(see responsive images). - Animate the cards in as they scroll into view, respecting
prefers-reduced-motion. - Use JavaScript to validate the form and show a thank-you message without reloading.
- Run Lighthouse in Chrome DevTools and aim for scores above 90 in every category.
Common Mistakes in First Portfolios
- Too many fonts and colours; one font family and one accent colour look more professional.
- Placeholder text left in, such as “Lorem ipsum” or broken links.
- No real projects; even small, finished projects with a short explanation are better than a list of skills.
- Not testing on a phone, where most recruiters first open your link.
Practice Exercises
Exercise 1. Add a “Skills” section between About and Contact that lists skills as tags using the existing .tags style.
Show answer
<section id="skills" class="container">
<h2>Skills</h2>
<ul class="tags"><li>HTML</li><li>CSS</li><li>JavaScript</li><li>Git</li></ul>
</section>
Also add <li><a href="#skills">Skills</a></li> to the navigation.
Exercise 2. Change the whole site’s accent colour to purple with one edit.
Show answer
:root { --brand: #6a1b9a; }
The hover shadow on the button uses a hard-coded green; change it to a purple rgba value too, or define it as a variable.
Frequently Asked Questions
Should I use a framework like Bootstrap for my portfolio?
For your first portfolio, plain HTML and CSS are better: the page is small, fast, and shows employers that you understand the fundamentals. Frameworks are useful later for large projects.
Why keep everything in one file?
It makes the tutorial easy to follow. For a real site, move the CSS into style.css and link it with <link rel="stylesheet" href="style.css">, so browsers can cache it across pages.
Summary
- A portfolio combines semantic HTML, variables, Flexbox, Grid, positioning and transitions.
auto-fitgrids andclamp()make the page responsive with little code.- Accessibility and meta tags are part of a finished page, not extras.
- Publish it for free on GitHub Pages, Netlify or Cloudflare Pages.
