Cara Membuat Website Pertama dengan HTML dan CSS
Tutorial step-by-step membuat website pertama dari nol menggunakan HTML dan CSS — lengkap dengan contoh kode dan tips untuk pemula.
Membuat website pertama bisa terasa menakutkan, tapi sebenarnya kamu hanya butuh dua hal: HTML untuk struktur dan CSS untuk tampilan. Tidak perlu install apapun — cukup text editor dan browser.
Persiapan
Yang kamu butuhkan:
- Text editor — VS Code (gratis, paling populer)
- Browser — Chrome, Firefox, atau Edge
- Semangat — Serius, itu saja!
Langkah 1: Buat Folder dan File
Buat folder baru, misalnya website-pertamaku, lalu buat dua file di dalamnya:
index.html— halaman utamastyle.css— file styling
Langkah 2: Struktur HTML
Buka index.html dan tulis:
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Portfolio Saya</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<header>
<nav>
<span class="logo">MySite</span>
<ul>
<li><a href="#about">About</a></li>
<li><a href="#skills">Skills</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section class="hero">
<h1>Halo! Saya <span class="highlight">Budi</span></h1>
<p>Seorang web developer pemula yang sedang belajar.</p>
<a href="#contact" class="btn">Hubungi Saya</a>
</section>
<section id="about">
<h2>Tentang Saya</h2>
<p>
Saya sedang belajar web development dari nol. Saat ini fokus
mempelajari HTML, CSS, dan JavaScript. Website ini adalah
proyek pertama saya!
</p>
</section>
<section id="skills">
<h2>Skills</h2>
<div class="skill-grid">
<div class="skill-card">
<h3>HTML</h3>
<p>Struktur halaman web</p>
</div>
<div class="skill-card">
<h3>CSS</h3>
<p>Styling dan layout</p>
</div>
<div class="skill-card">
<h3>JavaScript</h3>
<p>Sedang belajar...</p>
</div>
</div>
</section>
<section id="contact">
<h2>Hubungi Saya</h2>
<form>
<input type="text" placeholder="Nama" required />
<input type="email" placeholder="Email" required />
<textarea placeholder="Pesan" rows="4" required></textarea>
<button type="submit">Kirim</button>
</form>
</section>
</main>
<footer>
<p>© 2026 MySite. Dibuat dengan HTML & CSS.</p>
</footer>
</body>
</html>
Buka file ini di browser (double-click atau drag ke browser) — kamu akan lihat konten tanpa styling. Sekarang kita tambahkan CSS!
Langkah 3: Styling dengan CSS
Buka style.css dan tulis:
/* Reset dan base styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: system-ui, -apple-system, sans-serif;
line-height: 1.6;
color: #1a1a1a;
}
/* Navbar */
nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 2rem;
background: #1a1a1a;
color: white;
position: sticky;
top: 0;
}
.logo {
font-size: 1.5rem;
font-weight: bold;
color: #f97316;
}
nav ul {
display: flex;
list-style: none;
gap: 2rem;
}
nav a {
color: #d1d5db;
text-decoration: none;
transition: color 0.2s;
}
nav a:hover {
color: #f97316;
}
/* Hero section */
.hero {
text-align: center;
padding: 6rem 2rem;
background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
color: white;
}
.hero h1 {
font-size: 3rem;
margin-bottom: 1rem;
}
.highlight {
color: #f97316;
}
.hero p {
font-size: 1.2rem;
color: #9ca3af;
margin-bottom: 2rem;
}
.btn {
display: inline-block;
padding: 0.75rem 2rem;
background: #f97316;
color: white;
text-decoration: none;
border-radius: 8px;
font-weight: bold;
transition: background 0.2s;
}
.btn:hover {
background: #ea580c;
}
/* Sections */
section {
padding: 4rem 2rem;
max-width: 800px;
margin: 0 auto;
}
h2 {
font-size: 2rem;
margin-bottom: 1.5rem;
color: #1a1a1a;
}
/* Skill cards */
.skill-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1.5rem;
}
.skill-card {
padding: 2rem;
background: #f9fafb;
border-radius: 12px;
border: 1px solid #e5e7eb;
text-align: center;
}
.skill-card h3 {
color: #f97316;
margin-bottom: 0.5rem;
}
/* Contact form */
form {
display: flex;
flex-direction: column;
gap: 1rem;
}
input, textarea {
padding: 0.75rem 1rem;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 1rem;
font-family: inherit;
}
input:focus, textarea:focus {
outline: none;
border-color: #f97316;
box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}
button {
padding: 0.75rem 2rem;
background: #f97316;
color: white;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: bold;
cursor: pointer;
transition: background 0.2s;
}
button:hover {
background: #ea580c;
}
/* Footer */
footer {
text-align: center;
padding: 2rem;
background: #1a1a1a;
color: #9ca3af;
font-size: 0.875rem;
}
Refresh browser — sekarang website kamu punya desain yang rapi!
Langkah 4: Buat Responsif
Tambahkan di bagian bawah style.css:
/* Responsif untuk mobile */
@media (max-width: 640px) {
.hero h1 {
font-size: 2rem;
}
nav {
flex-direction: column;
gap: 1rem;
}
nav ul {
gap: 1rem;
}
}
Coba resize browser ke ukuran kecil — layout otomatis menyesuaikan.
Lihat CSS Bekerja Layer by Layer
Klik setiap layer atau tekan Play untuk melihat website terbentuk bertahap — dari HTML polos sampai desain lengkap:
Website Builder
CSS Layers
Preview
Aktifkan layer untuk melihat CSS bekerja
Apa yang Sudah Kamu Pelajari
Dari satu proyek kecil ini, kamu sudah menggunakan:
- HTML semantic —
<header>,<main>,<section>,<footer>,<nav> - CSS Flexbox — Untuk navbar dan form layout
- CSS Grid — Untuk skill cards
- Responsive design — Media queries untuk mobile
- Transitions — Hover effects yang smooth
- CSS Variables — Warna yang konsisten
- Box model — Padding, margin, border
- Form elements — Input, textarea, button
Tips untuk Pemula
- Jangan copy-paste — Ketik sendiri supaya otakmu terbiasa dengan syntax
- Eksperimen — Ubah-ubah nilai CSS dan lihat apa yang terjadi
- Inspect Element — Klik kanan di browser → Inspect untuk debug CSS
- Mulai dari mobile — Desain untuk layar kecil dulu, baru perbesar (mobile-first)
- Simpel dulu — Jangan langsung bikin yang kompleks, bangun pelan-pelan
Langkah Selanjutnya
Setelah proyek pertama ini:
- Deploy — Upload ke Netlify atau GitHub Pages (gratis!)
- JavaScript — Tambahkan interaktivitas (form yang berfungsi, animasi)
- Tailwind CSS — Framework CSS utility-first yang mempercepat styling
- Git — Mulai tracking perubahan kode dengan version control
Website pertama kamu mungkin sederhana — tapi ini langkah awal yang paling penting. Setiap developer senior pernah memulai dari titik yang sama.