HTML 2
HTML 2
Metode Pembelajaran
Setiap materi dalam buku ini dilengkapi dengan:
1. Penjelasan konsep dengan bahasa mudah dipahami
2. Perumpamaan dunia nyata untuk mempermudah pemahaman
3. Contoh kode yang bisa langsung dipraktikkan
4. Latihan soal untuk evaluasi mandiri
5. Tugas praktik dengan kode yang bisa diuji
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
</table>
<tr> Table Row Membuat baris baru Setiap baris punya tag ini
<td> Table Data Isi data biasa Teks normal dan rata kiri
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Contoh Tabel Sederhana</title>
</head>
<body>
<h1>Data Siswa Kelas X</h1>
<table border="1">
<tr>
<th>No</th>
<th>Nama Lengkap</th>
<th>Kelas</th>
<th>Nilai Rata-rata</th>
</tr>
<tr>
<td>1</td>
<td>Budi Santoso</td>
<td>X-A</td>
<td>88.5</td>
</tr>
<tr>
<td>2</td>
<td>Ani Wijaya</td>
<td>X-A</td>
<td>92.0</td>
</tr>
<tr>
<td>3</td>
<td>Citra Dewi</td>
<td>X-B</td>
<td>85.5</td>
</tr>
</table>
</body>
</html>
Penjelasan:
- border="1" memberi garis tepi pada tabel dan sel-selnya
- Setiap <tr> mewakili satu baris data
- Di dalam <tr>, kita punya 4 <th> (untuk baris pertama) atau 4 <td> (untuk
baris data)
<table border="1"
cellpadding="10"
cellspacing="0"
width="80%"
align="center"
bgcolor="#f9f9f9">
<!-- isi tabel -->
</table>
<table border="1">
<tr>
<th colspan="2">Data Gabungan 2 Kolom</th>
</tr>
<tr>
<td>Kolom 1</td>
<td>Kolom 2</td>
</tr>
</table>
<table border="1">
<tr>
<td rowspan="2">Gabung 2 Baris</td>
<td>Baris 1 Kolom 2</td>
</tr>
<tr>
<td>Baris 2 Kolom 2</td>
</tr>
</table>
<!DOCTYPE html>
<html>
<head>
<title>Jadwal Pelajaran</title>
</head>
<body>
<h1 style="text-align: center;">Jadwal Pelajaran Kelas X-A</h1>
<!DOCTYPE html>
<html>
<head>
<title>Tabel Produk</title>
</head>
<body>
<h2>Daftar Produk Unggulan</h2>
<table border="1" cellpadding="12" cellspacing="0" width="100%">
<tr bgcolor="#4CAF50" style="color: white;">
<th>ID Produk</th>
<th>Nama Produk</th>
<th>Kategori</th>
<th>Harga</th>
<th>Stok</th>
</tr>
<tr>
<td>PRD001</td>
<td>Smartphone XYZ</td>
<td>Elektronik</td>
<td>Rp2.500.000</td>
<td bgcolor="#90EE90">Tersedia</td>
</tr>
<tr>
<td>PRD002</td>
<td>Kemeja Casual</td>
<td>Fashion</td>
<td>Rp150.000</td>
<td bgcolor="#FFCCCC">Habis</td>
</tr>
<tr bgcolor="#f5f5f5">
<td>PRD003</td>
<td>Buku HTML Master</td>
<td>Buku</td>
<td>Rp85.000</td>
<td bgcolor="#90EE90">Tersedia</td>
</tr>
<tr>
<td colspan="3" align="right"><b>Total Nilai Stok:</b></td>
<td colspan="2"><b>Rp2.735.000</b></td>
</tr>
</table>
</body>
</html>
Latihan Soal
Soal 1: Tag apa yang digunakan untuk membuat baris dalam tabel?
A. <td>
B. <tr> ✓
C. <th>
D. <row>
Jawaban: B
<tr> (Table Row) adalah tag yang membuat baris baru dalam tabel. <td> untuk sel
data, <th> untuk header.*
Jawaban: C
<th> (Table Header) digunakan untuk sel judul. Secara default, teks di <th> akan
tebal dan berada di tengah.
Jawaban: B
colspan (column span) menggabungkan beberapa kolom menjadi satu sel.
Kebalikannya rowspan untuk baris.
Praktik Langsung
Tugas: Buat tabel nilai siswa dengan ketentuan:
- 4 kolom: No, Nama, Matematika, Bahasa Inggris, Rata-rata
- Minimal 3 baris data
- Gunakan colspan untuk judul utama "Laporan Nilai Semester 1"
- Gunakan rowspan jika ada data yang sama
Kode referensi:
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Latihan Tabel - Nilai Siswa</title>
</head>
<body>
<h2 align="center">Laporan Nilai Semester 1</h2>
Pengertian Form
Form atau formulir adalah elemen HTML yang digunakan untuk mengumpulkan
input dari pengguna. Ini adalah jembatan antara pengunjung website dengan
pemilik website. Setiap kali Anda login ke media sosial, mencari produk di e-
commerce, mengisi survei, atau mendaftar newsletter - Anda sedang menggunakan
form!
8. Range Slider
9. Color Picker
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Form Pendaftaran</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input, select, textarea {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.radio-group, .checkbox-group {
display: flex;
gap: 20px;
}
.radio-group label, .checkbox-group label {
font-weight: normal;
display: inline;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h1>Form Pendaftaran Member</h1>
<p>Silakan isi data diri Anda dengan lengkap.</p>
<script>
// Menampilkan nilai range slider
const range = [Link]('kepuasan');
const output = [Link]('nilai_kepuasan');
[Link] = function() {
[Link] = [Link];
}
</script>
</body>
</html>
<fieldset>
<legend>Informasi Pribadi</legend>
<input type="text" name="nama" placeholder="Nama">
<input type="email" name="email" placeholder="Email">
</fieldset>
<fieldset>
<legend>Informasi Akun</legend>
<input type="text" name="username" placeholder="Username">
<input type="password" name="password" placeholder="Password">
</fieldset>
Latihan Soal
Soal 1: Tag apa yang digunakan untuk membuat input teks?
A. <text>
B. <input type='text'> ✓
C. <input text>
D. <textbox>
Jawaban: B
<input type="text"> adalah cara yang benar. Atribut type menentukan jenis input.
Jawaban: C
type="password" menampilkan bullet point atau bintang sebagai pengganti karakter
yang diketik.
Jawaban: B
Radio button dengan name yang sama hanya bisa dipilih satu. Checkbox bisa
memilih banyak opsi.
Praktik Langsung
Tugas: Buat form kontak sederhana dengan:
- Nama (text, required)
- Email (email, required)
- Pesan (textarea)
- Prioritas (select: Rendah, Sedang, Tinggi)
- Tombol submit
Kode referensi:
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Form Kontak - Latihan</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
max-width: 500px;
margin: 50px auto;
padding: 20px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.form-container {
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
h1 {
text-align: center;
color: #333;
margin-bottom: 30px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
input, select, textarea {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 14px;
box-sizing: border-box;
}
textarea {
resize: vertical;
}
button {
width: 100%;
padding: 12px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
button:hover {
opacity: 0.9;
}
.required:after {
content: " *";
color: red;
}
</style>
</head>
<body>
<div class="form-container">
<h1>� Hubungi Kami</h1>
<div class="form-group">
<label class="required">Alamat Email</label>
<input type="email" name="email" placeholder="email@[Link]" required>
</div>
<div class="form-group">
<label>Prioritas</label>
<select name="prioritas">
<option value="rendah">� Rendah</option>
<option value="sedang" selected>� Sedang</option>
<option value="tinggi">� Tinggi</option>
</select>
</div>
<div class="form-group">
<label>Pesan</label>
<textarea name="pesan" rows="5" placeholder="Tulis pesan Anda di sini..."></textarea>
</div>
Mengelompokkan Elemen
<!DOCTYPE html>
<html>
<head>
<style>
.container {
background-color: #f0f0f0;
padding: 20px;
margin: 10px;
border-radius: 10px;
}
.header {
background-color: #4CAF50;
color: white;
padding: 15px;
text-align: center;
}
.content {
background-color: white;
padding: 20px;
margin-top: 10px;
}
.footer {
background-color: #333;
color: white;
padding: 10px;
text-align: center;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Website Saya</h1>
</div>
<div class="content">
<h2>Selamat Datang</h2>
<p>Ini adalah konten utama website.</p>
<p>Div membantu kita mengelompokkan dan memberi gaya.</p>
</div>
<div class="footer">
<p>Copyright 2024</p>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
.highlight {
background-color: yellow;
font-weight: bold;
}
.important {
color: red;
font-size: 1.2em;
}
.price {
color: green;
font-weight: bold;
}
.old-price {
text-decoration: line-through;
color: gray;
}
</style>
</head>
<body>
<h1>Belajar <span class="highlight">Span</span> di HTML</h1>
<p>
Ini adalah kalimat dengan kata
<span class="important">PENTING</span>
yang diberi warna merah dan ukuran lebih besar.
</p>
<p>
Harga: <span class="old-price">Rp100.000</span>
<span class="price">Rp75.000</span>
</p>
<p>
Status: <span style="color: green; font-weight: bold;">✓ Tersedia</span>
</p>
</body>
</html>
Mewarnai satu kata dalam kalimat <span> Inline, tidak merusak aliran teks
Memberi gaya pada sebagian teks <span> Presisi pada teks pendek
Ikon atau badge dalam teks <span> Inline, bisa di samping teks
<!DOCTYPE html>
<html>
<head>
<style>
/* Styling untuk div */
.card {
width: 300px;
background: white;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
padding: 20px;
margin: 20px;
transition: transform 0.3s;
}
.card:hover {
transform: translateY(-5px);
}
Tips Profesional
1. Gunakan div dengan class yang deskriptif - class="product-card" lebih baik dari
class="box1"
2. Jangan terlalu banyak div bersarang - "Div-itis" membuat kode sulit dibaca
3. Untuk layout, pertimbangkan semantic HTML5 - <header>, <main>, <footer>
lebih baik dari <div class="header">
4. Span untuk micro-interactions - Bisa diberi event JavaScript tanpa merusak
layout
5. Kombinasikan div dan span - Div untuk struktur, span untuk detail
Latihan Soal
Soal 1: Tag mana yang bersifat block (membuat baris baru)?
A. <span>
B. <div> ✓
C. Keduanya block
D. Keduanya inline
Jawaban: B
<div> adalah block element yang membuat baris baru. <span> adalah inline
element.
Jawaban: B
<span> ideal untuk membungkus teks pendek di dalam paragraf atau heading tanpa
mengganggu aliran teks.
Jawaban: B
Sebagai block element, <div> bisa diatur lebar dan tinggi. <span> sebagai inline
element tidak merespon width/height.
Praktik Langsung
Tugas: Buat halaman profil produk dengan:
- Container div untuk seluruh halaman
- Div untuk header produk
- Div untuk galeri gambar (3 gambar)
- Div untuk informasi produk
- Span untuk harga, span untuk diskon, span untuk status stok
Kode referensi:
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Latihan Div dan Span - Halaman Produk</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f5f5f5;
padding: 20px;
}
/* Container utama */
.product-container {
max-width: 1000px;
margin: 0 auto;
background: white;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}
/* Header produk */
.product-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
}
.product-header h1 {
font-size: 28px;
margin-bottom: 10px;
}
/* Galeri gambar */
.gallery {
display: flex;
gap: 15px;
padding: 30px;
background: #fafafa;
}
.gallery-item {
flex: 1;
background: white;
border-radius: 10px;
padding: 20px;
text-align: center;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.gallery-item img {
width: 100%;
height: 150px;
object-fit: cover;
border-radius: 8px;
}
/* Informasi produk */
.product-info {
padding: 30px;
}
.price-section {
background: #e8f5e9;
padding: 20px;
border-radius: 10px;
margin-bottom: 20px;
}
.current-price {
color: #4CAF50;
font-size: 28px;
font-weight: bold;
}
.discount-badge {
background-color: #ff9800;
color: white;
padding: 5px 10px;
border-radius: 20px;
font-size: 14px;
margin-left: 15px;
}
.stock-status {
display: inline-block;
padding: 5px 15px;
border-radius: 20px;
font-size: 14px;
font-weight: bold;
}
.stock-available {
background-color: #4CAF50;
color: white;
}
.stock-low {
background-color: #ff9800;
color: white;
}
.feature-list {
list-style: none;
margin-top: 20px;
}
.feature-list li {
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.feature-icon {
font-size: 20px;
margin-right: 10px;
}
.btn-buy {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 15px 30px;
font-size: 18px;
border-radius: 50px;
cursor: pointer;
width: 100%;
margin-top: 20px;
transition: transform 0.3s;
}
.btn-buy:hover {
transform: scale(1.02);
}
</style>
</head>
<body>
<div class="product-container">
<!-- Header Produk -->
<div class="product-header">
<h1>SmartWatch Pro X</h1>
<p>Jam Tangan Pintar Generasi Terbaru</p>
</div>
<div>
Status Stok:
<span class="stock-status stock-available">✓ Tersedia</span>
</div>
<ul class="feature-list">
<li>
<span class="feature-icon">�</span>
<span>Layar AMOLED 1.75 inci</span>
</li>
<li>
<span class="feature-icon">❤ </span>
<span>Sensor detak jantung & SpO2</span>
</li>
<li>
<span class="feature-icon">�</span>
<span>20 mode olahraga</span>
</li>
<li>
<span class="feature-icon">�</span>
<span>Tahan air IP68</span>
</li>
<li>
<span class="feature-icon">�</span>
<span>Baterai tahan 7 hari</span>
</li>
</ul>
<button class="btn-buy">
<span>�</span> Beli Sekarang
</button>
</div>
</div>
</body>
</html>
MATERI 4: SEMANTIC HTML
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Semantic HTML - Website Modern</title>
</head>
<body>
<!-- HEADER: Logo dan judul utama -->
<header>
<h1>Website Saya</h1>
<p>Belajar Semantic HTML untuk website modern</p>
<article>
<h3>Memahami Semantic HTML</h3>
<p>Pengenalan tentang tag-tag semantic...</p>
</article>
<article>
<h3>Tips SEO untuk Pemula</h3>
<p>Cara meningkatkan peringkat website...</p>
</article>
</section>
<h3>Kategori</h3>
<ul>
<li><a href="#">HTML (10)</a></li>
<li><a href="#">CSS (8)</a></li>
<li><a href="#">JavaScript (5)</a></li>
</ul>
</aside>
</main>
<div class="header">
<div class="logo">Website Saya</div>
<div class="nav">
<div class="menu-item">Beranda</div>
<div class="menu-item">Tentang</div>
</div>
</div>
<div class="main">
<div class="content">
<div class="post-title">Judul Artikel</div>
<div class="post-content">Isi artikel...</div>
</div>
<div class="sidebar">Sidebar...</div>
</div>
<header>
<h1>Website Saya</h1>
<nav>
<a href="#">Beranda</a>
<a href="#">Tentang</a>
</nav>
</header>
<main>
<article>
<h2>Judul Artikel</h2>
<p>Isi artikel...</p>
</article>
<aside>Sidebar...</aside>
</main>
<footer>Copyright 2024</footer>
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Blog Semantic - Tutorial HTML</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Georgia', serif;
line-height: 1.6;
color: #333;
background: #f4f4f4;
}
/* Header styling */
header {
background: #2c3e50;
color: white;
padding: 1rem;
text-align: center;
}
header h1 {
margin-bottom: 0.5rem;
}
/* Navigation styling */
nav {
background: #34495e;
padding: 0.5rem;
text-align: center;
}
nav a {
color: white;
text-decoration: none;
margin: 0 1rem;
padding: 0.5rem;
}
nav a:hover {
background: #2c3e50;
border-radius: 5px;
}
/* Article styling */
article {
background: white;
padding: 1.5rem;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
margin-bottom: 1.5rem;
}
article header {
background: none;
color: #333;
padding: 0;
text-align: left;
margin-bottom: 1rem;
}
article h2 {
color: #2c3e50;
margin-bottom: 0.5rem;
}
.meta {
color: #7f8c8d;
font-size: 0.9rem;
}
/* Figure styling */
figure {
margin: 1rem 0;
}
figcaption {
text-align: center;
font-size: 0.85rem;
color: #7f8c8d;
margin-top: 0.5rem;
}
/* Aside styling */
aside {
background: white;
padding: 1.5rem;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
height: fit-content;
}
aside h3 {
color: #2c3e50;
margin-bottom: 1rem;
border-bottom: 2px solid #3498db;
padding-bottom: 0.5rem;
}
aside ul {
list-style: none;
}
aside li {
margin-bottom: 0.5rem;
}
aside a {
color: #3498db;
text-decoration: none;
}
aside a:hover {
text-decoration: underline;
}
/* Footer styling */
footer {
background: #2c3e50;
color: white;
text-align: center;
padding: 1rem;
margin-top: 2rem;
}
/* Mark styling */
mark {
background: #f39c12;
color: white;
padding: 0.2rem 0.5rem;
border-radius: 3px;
}
summary {
font-weight: bold;
cursor: pointer;
color: #2c3e50;
}
<nav>
<a href="#home">� Beranda</a>
<a href="#tutorial">� Tutorial</a>
<a href="#about">� Tentang</a>
<a href="#contact">� Kontak</a>
</nav>
<main>
<!-- Konten Utama -->
<div>
<article>
<header>
<h2>Mengapa Semantic HTML Penting?</h2>
<div class="meta">
<time datetime="2024-01-20">20 Januari 2024</time> |
Oleh <strong>Ahmad Wijaya</strong> |
<span>� 5 menit membaca</span>
</div>
</header>
<p>
Semantic HTML adalah fondasi website modern. Dengan menggunakan tag yang tepat,
kita membantu <mark>mesin pencari</mark> dan <mark>pembaca layar</mark>
memahami struktur konten kita.
</p>
<figure>
<img src="[Link] alt="Ilustrasi semantic HTML"
width="100%">
<figcaption>Gambar 1: Struktur semantic HTML yang rapi dan
terorganisir</figcaption>
</figure>
<p>
Bayangkan jika semua bagian website menggunakan tag <div>. Mesin pencari
tidak akan bisa membedakan mana header, mana artikel, mana footer. Dengan
semantic
HTML, Google bisa memahami hierarki konten dengan lebih baik.
</p>
<details>
<summary>� Baca Juga: Tips Semantic HTML</summary>
<p>
Gunakan <header> untuk bagian atas, <nav> untuk menu,
<main> untuk konten utama (hanya satu per halaman),
<article> untuk konten independen, <aside> untuk sidebar,
dan <footer> untuk bagian bawah.
</p>
</details>
</article>
<article>
<header>
<h2>Perbandingan: Div vs Semantic Tags</h2>
<div class="meta">
<time datetime="2024-01-18">18 Januari 2024</time> |
Oleh <strong>Ahmad Wijaya</strong>
</div>
</header>
<p>
Banyak developer pemula masih menggunakan <div> untuk semuanya.
Padahal, dengan semantic tags, kode menjadi lebih <mark>readable</mark>
dan <mark>maintainable</mark>.
</p>
<details>
<summary>� Lihat Contoh Kode</summary>
<pre style="background: #2c3e50; color: #ecf0f1; padding: 1rem; border-radius: 5px;
overflow-x: auto;">
<!-- Non-semantic (kurang baik) -->
<div class="header">...</div>
<div class="nav">...</div>
<h3> Tags</h3>
<p>
<mark style="background: #3498db;">#HTML</mark>
<mark style="background: #e74c3c;">#Semantic</mark>
<mark style="background: #2ecc71;">#SEO</mark>
<mark style="background: #f39c12;">#Accessibility</mark>
</p>
</aside>
</main>
<footer>
<p>© 2024 Blog Semantic HTML. All rights reserved.</p>
<p>
<a href="#" style="color: white;">Privacy Policy</a> |
<a href="#" style="color: white;">Terms of Service</a> |
<a href="#" style="color: white;">Contact</a>
</p>
</footer>
</body>
</html>
Latihan Soal
Soal 1: Tag semantic apa yang digunakan untuk navigasi?
A. <header>
B. <nav> ✓
C. <menu>
D. <navigation>
Jawaban: B
<nav> adalah tag semantic untuk menu navigasi. Tag ini memberi tahu browser
bahwa ini adalah bagian untuk berpindah halaman.
Jawaban: B
Semantic HTML membantu mesin pencari (SEO) memahami struktur konten dan
membantu screen reader (aksesibilitas) untuk pengguna tunanetra.
Soal 3: Berapa banyak tag <main> yang boleh dalam satu halaman?
A. Tidak ada batasan
B. Maksimal 2
C. Hanya 1 ✓
D. Minimal 3
Jawaban: C
Hanya boleh ada satu <main> per halaman karena ini mewakili konten utama yang
unik untuk halaman tersebut.
Praktik Langsung
Tugas: Buat halaman portofolio sederhana dengan struktur semantic:
- Header dengan judul dan navigasi
- Main dengan beberapa artikel proyek
- Aside untuk info kontak
- Footer dengan copyright
Kode referensi:
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Portofolio Saya - Semantic HTML</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: #333;
}
header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
text-align: center;
padding: 3rem 1rem;
}
header h1 {
font-size: 2.5rem;
margin-bottom: 0.5rem;
}
nav {
background: #2c3e50;
padding: 1rem;
text-align: center;
position: sticky;
top: 0;
}
nav a {
color: white;
text-decoration: none;
margin: 0 1rem;
padding: 0.5rem 1rem;
border-radius: 5px;
transition: background 0.3s;
}
nav a:hover {
background: #34495e;
}
main {
max-width: 1200px;
margin: 2rem auto;
padding: 0 1rem;
display: grid;
grid-template-columns: 2fr 1fr;
gap: 2rem;
}
article {
background: #f9f9f9;
border-radius: 10px;
overflow: hidden;
margin-bottom: 1.5rem;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
transition: transform 0.3s;
}
article:hover {
transform: translateY(-5px);
}
.project-img {
width: 100%;
height: 200px;
object-fit: cover;
}
.project-content {
padding: 1.5rem;
}
.project-content h3 {
color: #667eea;
margin-bottom: 0.5rem;
}
.project-tags {
margin-top: 1rem;
}
.project-tags span {
display: inline-block;
background: #e0e0e0;
padding: 0.2rem 0.8rem;
border-radius: 20px;
font-size: 0.8rem;
margin-right: 0.5rem;
}
aside {
background: #f9f9f9;
padding: 1.5rem;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
height: fit-content;
}
aside h3 {
color: #667eea;
margin-bottom: 1rem;
border-bottom: 2px solid #667eea;
padding-bottom: 0.5rem;
}
.contact-info {
list-style: none;
}
.contact-info li {
margin-bottom: 0.8rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.skill-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-top: 0.5rem;
}
.skill-list span {
background: #667eea;
color: white;
padding: 0.3rem 0.8rem;
border-radius: 20px;
font-size: 0.8rem;
}
footer {
background: #2c3e50;
color: white;
text-align: center;
padding: 1.5rem;
margin-top: 2rem;
}
<nav>
<a href="#home">� Beranda</a>
<a href="#projects">� Proyek</a>
<a href="#skills">� Skill</a>
<a href="#contact">� Kontak</a>
</nav>
<main>
<div>
<h2 style="margin-bottom: 1.5rem; color: #667eea;">� Proyek Unggulan</h2>
<article>
<img class="project-img" src="[Link] alt="Proyek
Website E-commerce">
<div class="project-content">
<h3>Website E-commerce Modern</h3>
<p>
Platform belanja online dengan fitur keranjang belanja,
payment gateway, dan sistem review produk. Dibangun dengan
HTML5 semantic, CSS3, dan JavaScript.
</p>
<div class="project-tags">
<span>#HTML5</span>
<span>#CSS3</span>
<span>#JavaScript</span>
<span>#Responsive</span>
</div>
</div>
</article>
<article>
<img class="project-img" src="[Link] alt="Proyek Blog
Platform">
<div class="project-content">
<h3>Platform Blogging</h3>
<p>
Sistem blog dengan struktur semantic HTML yang optimal untuk SEO.
Mendukung komentar, kategori, dan pencarian artikel.
</p>
<div class="project-tags">
<span>#SemanticHTML</span>
<span>#SEO</span>
<span>#Accessibility</span>
</div>
</div>
</article>
<article>
<img class="project-img" src="[Link] alt="Proyek Portfolio
Gallery">
<div class="project-content">
<h3>Portfolio Gallery Interaktif</h3>
<p>
Galeri portofolio dengan filter kategori dan lightbox preview.
Menggunakan semantic HTML dan CSS Grid untuk layout yang rapi.
</p>
<div class="project-tags">
<span>#CSSGrid</span>
<span>#Flexbox</span>
<span>#Responsive</span>
</div>
</div>
</article>
</div>
<aside>
<h3>� Profil Singkat</h3>
<img src="[Link] alt="Foto profil" style="width:
100px; border-radius: 50%; display: block; margin: 0 auto 1rem;">
<p style="text-align: center; margin-bottom: 1.5rem;">
Web developer dengan 3+ tahun pengalaman. Fokus pada semantic HTML,
performa website, dan user experience.
</p>
<h3>� Kontak</h3>
<ul class="contact-info">
<li>� ahmad@[Link]</li>
<li>� +62 812 3456 7890</li>
<li>� [Link]/ahmadwijaya</li>
<li>� [Link]/in/ahmadwijaya</li>
</ul>
<footer>
<p>© 2024 Ahmad Wijaya - Portofolio dengan Semantic HTML</p>
<p style="margin-top: 0.5rem; font-size: 0.8rem;">
Dibangun dengan tag semantic: header, nav, main, article, aside, footer
</p>
</footer>
</body>
</html>
BAB 3: MULTIMEDIA DAN INTEGRASI
MATERI 5: AUDIO DAN VIDEO
Tag Audio
Struktur dasar audio:
<audio controls>
<source src="musik.mp3" type="audio/mpeg">
<source src="[Link]" type="audio/ogg">
Browser Anda tidak mendukung tag audio.
</audio>
Tag Video
Struktur dasar video:
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Audio dan Video - Belajar Multimedia</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.container {
background: white;
border-radius: 15px;
padding: 30px;
margin-bottom: 20px;
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
h1, h2 {
color: #333;
}
.demo {
background: #f5f5f5;
padding: 20px;
border-radius: 10px;
margin: 20px 0;
}
video {
max-width: 100%;
border-radius: 10px;
}
audio {
width: 100%;
}
.tips {
background: #e8f5e9;
padding: 15px;
border-radius: 8px;
margin-top: 20px;
}
.tips h3 {
color: #2e7d32;
margin-top: 0;
}
</style>
</head>
<body>
<div class="container">
<h1>� HTML5 Audio & Video</h1>
<p>Menambahkan multimedia ke website dengan tag <code><audio></code> dan
<code><video></code></p>
<div class="demo">
<h3>Audio dengan Autoplay & Loop (dengan mute)</h3>
<audio controls autoplay loop muted>
<source src="[Link]
type="audio/mpeg">
Browser Anda tidak mendukung audio.
</audio>
<p><small>� Audio akan loop terus. Mute diaktifkan agar tidak
mengagetkan.</small></p>
</div>
<!-- ========== VIDEO ========== -->
<h2>� Contoh Video Player</h2>
<div class="demo">
<h3>Video dengan Poster (Thumbnail)</h3>
<video width="100%" controls poster="[Link]
<source src="[Link]
bucket/sample/ForBiggerBlazes.mp4" type="video/mp4">
Browser Anda tidak mendukung video.
</video>
<p><small>� Video sampel dari Google (Big Buck Bunny)</small></p>
</div>
<div class="demo">
<h3>Video Responsive (lebar 100%)</h3>
<video width="100%" controls>
<source src="[Link]
bucket/sample/ForBiggerEscapes.mp4" type="video/mp4">
<source src="[Link]
bucket/sample/[Link]" type="video/webm">
Browser Anda tidak mendukung video.
</video>
</div>
<!-- ========== TIPS ========== -->
<div class="tips">
<h3>� Tips Penggunaan Audio & Video</h3>
<ul>
<li>Sediakan <strong>multiple format</strong> (MP4 + WebM) untuk
kompatibilitas</li>
<li>Gunakan <strong>poster</strong> untuk video agar lebih menarik sebelum di-
play</li>
<li><strong>Autoplay</strong> biasanya diblokir browser kecuali video
<strong>muted</strong></li>
<li>Optimasi ukuran file video untuk performa website</li>
<li>Gunakan <strong>lazy loading</strong> untuk video di luar layar pertama</li>
</ul>
</div>
</div>
</body>
</html>
Video dari YouTube/External
Untuk menyisipkan video dari YouTube, gunakan iframe (akan dipelajari di materi
selanjutnya):
<style>
.custom-audio {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 20px;
border-radius: 50px;
}
.custom-video {
border: 3px solid #667eea;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
</style>
<div class="custom-audio">
<audio controls>
<source src="musik.mp3" type="audio/mpeg">
</audio>
</div>
Pro Tips
1. Sediakan fallback teks - Untuk browser yang tidak mendukung
2. Multiple sources - Berikan MP4 dan WebM untuk kompatibilitas maksimal
3. Jangan autoplay dengan suara - Mengganggu pengguna dan diblokir browser
4. Optimasi file - Kompres video untuk kecepatan loading
5. Gunakan CDN - Hosting video di layanan seperti YouTube, Vimeo
Latihan Soal
Soal 1: Tag apa untuk menampilkan video di HTML5?
A. <media>
B. <movie>
C. <video> ✓
D. <film>
Jawaban: C
<video> adalah tag HTML5 yang benar untuk menampilkan video. Tag ini didukung
semua browser modern.
Jawaban: B
Atribut controls menampilkan kontrol pemutaran (play, pause, volume, fullscreen)
pada elemen audio/video.
Soal 3: Mengapa kita perlu menyediakan multiple source (MP4 dan WebM)?
A. Agar video lebih bagus
B. Untuk kompatibilitas antar browser ✓
C. Agar ukuran lebih kecil
D. Tidak ada alasan
Jawaban: B
Tidak semua browser mendukung format yang sama. MP4 didukung semua browser,
WebM sebagai alternatif untuk browser tertentu.
Praktik Langsung
Tugas: Buat halaman media player dengan:
- 1 audio player dengan controls
- 1 video player dengan poster (thumbnail)
- Tambahkan deskripsi dan informasi durasi
- Gunakan styling yang menarik
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Media Player - Latihan Audio Video</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background: #0f0f0f;
color: white;
padding: 20px;
}
.player-container {
max-width: 800px;
margin: 0 auto;
}
.card {
background: #1e1e1e;
border-radius: 15px;
padding: 20px;
margin-bottom: 30px;
}
.card h2 {
margin-top: 0;
color: #1DB954;
}
audio {
width: 100%;
margin: 15px 0;
}
video {
width: 100%;
border-radius: 10px;
margin: 15px 0;
}
.info {
color: #aaa;
font-size: 0.9em;
}
</style>
</head>
<body>
<div class="player-container">
<h1>� Media Player Demo</h1>
Pengertian Iframe
Iframe (Inline Frame) adalah tag HTML yang digunakan untuk menyisipkan halaman
web lain ke dalam halaman web kita. Ini seperti "jendela" yang menampilkan
website lain di dalam website kita.
<iframe src="[Link]
width="800"
height="600"
title="Deskripsi iframe">
</iframe>
<iframe
src="[Link]
6.828677!3d-
6.208670!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x2e69f3e945e34b9d%3A0x53
71bf0fdad786a2!2sMonas!5e0!3m2!1sid!2sid!4v1234567890"
width="600"
height="450"
style="border:0;"
allowfullscreen=""
loading="lazy">
</iframe>
<iframe src="[Link]
width="550"
height="600"
title="Tweet">
</iframe>
<iframe src="[Link]"
width="100%"
height="600"
title="PDF Viewer">
</iframe>
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Iframe - Menyisipkan Konten</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background: #f5f5f5;
}
h1 {
text-align: center;
color: #333;
}
.iframe-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
gap: 20px;
}
.iframe-card {
background: white;
border-radius: 10px;
padding: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.iframe-card h2 {
margin-top: 0;
color: #667eea;
}
iframe {
width: 100%;
border-radius: 8px;
border: 1px solid #ddd;
}
.note {
background: #fff3cd;
border-left: 4px solid #ffc107;
padding: 10px;
margin: 20px 0;
}
</style>
</head>
<body>
<h1> Belajar Iframe - Menyisipkan Kontek Eksternal</h1>
<div class="note">
<strong>� Catatan:</strong> Beberapa website (seperti Google, Facebook)
memblokir iframe untuk keamanan. Gunakan layanan yang menyediakan embed code.
</div>
<div class="iframe-grid">
<!-- YouTube Video -->
<div class="iframe-card">
<h2>� YouTube Video</h2>
<iframe width="100%" height="315"
src="[Link]
title="YouTube video"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-
in-picture"
allowfullscreen>
</iframe>
<p><small>Ganti VIDEO_ID dengan ID video YouTube yang ingin
ditampilkan</small></p>
</div>
src="[Link]
8677!3d-
6.208670!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x2e69f3e945e34b9d%3A0x5371bf
0fdad786a2!2sMonas!5e0!3m2!1sid!2sid!4v1234567890"
width="100%"
height="315"
style="border:0;"
allowfullscreen=""
loading="lazy">
</iframe>
<p><small>Lokasi Monumen Nasional (Monas), Jakarta</small></p>
</div>
Responsive Iframe
Membuat iframe responsive (menyesuaikan lebar layar):
<style>
.iframe-container {
position: relative;
width: 100%;
padding-bottom: 56.25%; /* Ratio 16:9 */
height: 0;
overflow: hidden;
}
.iframe-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<div class="iframe-container">
<iframe src="[Link] allowfullscreen></iframe>
</div>
Latihan Soal
Soal 1: Tag apa untuk menyisipkan halaman web lain?
A. <frame>
B. <iframe> ✓
C. <embed>
D. <object>
Jawaban: B
<iframe> adalah tag yang benar untuk menyisipkan halaman web ke halaman lain.
Tag <frame> sudah usang (deprecated).
Jawaban: B
sandbox memberi batasan keamanan pada konten iframe, mencegah akses ke fitur
tertentu yang berpotensi berbahaya.
Praktik Langsung
Tugas: Buat halaman yang berisi:
- Video YouTube favorit Anda (gunakan embed code)
- Peta lokasi rumah/kantor (Google Maps)
- Embed Instagram post atau Tweet
Kode referensi:
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>My Embed Collection - Latihan Iframe</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
margin: 0;
padding: 20px;
}
.container {
max-width: 1000px;
margin: 0 auto;
}
.card {
background: white;
border-radius: 15px;
padding: 20px;
margin-bottom: 30px;
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.card h2 {
margin-top: 0;
color: #667eea;
}
.responsive-iframe {
position: relative;
width: 100%;
padding-bottom: 56.25%;
height: 0;
}
.responsive-iframe iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 10px;
}
.info {
background: #f0f0f0;
padding: 10px;
border-radius: 8px;
margin-top: 15px;
font-size: 0.9em;
}
</style>
</head>
<body>
<div class="container">
<h1 style="color: white; text-align: center;">� My Embed Collection</h1>
src="[Link]
8677!3d-
6.208670!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x2e69f3e945e34b9d%3A0x5371bf
0fdad786a2!2sMonas!5e0!3m2!1sid!2sid!4v1234567890"
style="border:0;"
allowfullscreen=""
loading="lazy">
</iframe>
</div>
<div class="info">
� Ganti koordinat dengan lokasi yang diinginkan
</div>
</div>
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Karakter Khusus HTML</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
.demo {
background: #f5f5f5;
padding: 15px;
margin: 10px 0;
border-left: 4px solid #667eea;
}
code {
background: #e0e0e0;
padding: 2px 5px;
border-radius: 3px;
font-family: monospace;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background: #667eea;
color: white;
}
</style>
</head>
<body>
<h1>� HTML Entities (Karakter Khusus)</h1>
<div class="demo">
<h2>� Menampilkan Tag HTML</h2>
<p>Untuk menampilkan tag HTML sebagai teks, gunakan <code>&lt;</code> dan
<code>&gt;</code></p>
<p>Contoh: <code><div> ini adalah tag div </div></code></p>
<p>Hasil: <div> ini adalah tag div </div></p>
</div>
<div class="demo">
<h2>� Simbol Mata Uang</h2>
<p>Harga: 100 € (Euro) | 50 £ (Pound) | 1000 ¥ (Yen) | 99 ¢
(Cent)</p>
<p>Kode: <code>&euro; &pound; &yen; &cent;</code></p>
</div>
<div class="demo">
<h2>� Simbol Matematika</h2>
<p>Suhu: 25°C | 10 ± 2 | 5 × 3 = 15 | 10 ÷ 2 = 5</p>
<p>Perbandingan: x ≤ 10 | y ≥ 5 | a ≠ b</p>
</div>
<div class="demo">
<h2>➡ Simbol Panah</h2>
<p>Navigasi: ← Kiri | → Kanan | ↑ Atas | ↓ Bawah</p>
<p>⇐ ⇒ ⇑ ⇓ (Double arrow)</p>
</div>
<div class="demo">
<h2>� Simbol Lainnya</h2>
<p>Rating: ♥ ☆ ✓ ✗</p>
<p>Hak cipta: © 2024 | Merek: ® ™</p>
</div>
Menampilkan tag HTML < dan > Agar tidak dianggap tag
Latihan Soal
Soal 1: Kode karakter untuk simbol copyright (©) adalah?
A. © ✓
B. ©right;
C. &cr;
D. &c;
Jawaban: A
© adalah HTML entity yang benar untuk simbol copyright. Hasilnya akan
menampilkan ©.
Jawaban: B
Tanda < digunakan untuk membuka tag HTML. Jika ingin menampilkannya sebagai
teks, harus menggunakan < agar tidak dianggap sebagai tag.
Jawaban: B
(non-breaking space) adalah spasi yang menjaga dua kata tetap bersama di
baris yang sama.
Praktik Langsung
Tugas: Buat halaman yang menampilkan:
- Rumus matematika dengan simbol khusus
- Harga dalam berbagai mata uang
- Copyright notice di footer
- Menampilkan contoh kode HTML
Kode referensi:
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Latihan Karakter Khusus</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background: #f0f2f5;
}
.card {
background: white;
border-radius: 10px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.math {
font-size: 1.2em;
font-family: monospace;
background: #f5f5f5;
padding: 10px;
border-radius: 5px;
}
.price {
color: #2e7d32;
font-weight: bold;
}
footer {
text-align: center;
padding: 20px;
color: #666;
}
</style>
</head>
<body>
<h1>� Latihan Karakter Khusus HTML</h1>
<div class="card">
<h2>� Rumus Matematika</h2>
<div class="math">
<p>Rumus Pythagoras: a² + b² = c²</p>
<p>Rumus luas lingkaran: π × r²</p>
<p>Suhu: 25°C = 77°F</p>
<p>Perbandingan: x ≤ 10 dan y ≥ 5</p>
<p>Perkalian: 5 × 4 = 20</p>
<p>Pembagian: 20 ÷ 4 = 5</p>
</div>
</div>
<div class="card">
<h2>� Daftar Harga Produk</h2>
<ul>
<li>Laptop: <span class="price">$999 $</span> / <span class="price">€
899</span></li>
<li>Smartphone: <span class="price">£ 699</span> / <span class="price">¥
120,000</span></li>
<li>Headset: <span class="price">¢ 9,999</span></li>
</ul>
</div>
<div class="card">
<h2>� Contoh Kode HTML</h2>
<p>Cara menulis tag HTML di halaman web:</p>
<pre style="background: #2c3e50; color: #ecf0f1; padding: 10px; border-radius: 5px;">
<!DOCTYPE html>
<html>
<head>
<title>Judul Halaman</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html></pre>
</div>
<div class="card">
<h2>� Rating & Review</h2>
<p>Rating: ☆ ☆ ☆ ☆ ☆ (5/5)</p>
<p>Status: ✓ Tersedia | ✗ Habis</p>
<p>Favorite: ♥ ♥ ♥</p>
</div>
<footer>
<p>© 2024 Belajar HTML Entities | ® All Rights Reserved | ™ Trademark</p>
<p>Dibuat dengan ♥ untuk pembelajaran HTML</p>
</footer>
</body>
</html>
BAB 4: OPTIMASI DAN STYLING
MATERI 8: META TAGS
<head>
<meta charset="UTF-8">
<meta name="description" content="Deskripsi website">
<meta name="keywords" content="HTML, CSS, JavaScript">
<meta name="author" content="Nama Pembuat">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<meta charset="UTF-8">
<meta name="description" content="Belajar HTML dari nol sampai mahir dengan tutorial
praktis">
9. Twitter Card
<!DOCTYPE html>
<html lang="id">
<head>
<!-- ========== META DASAR ========== -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- ========== META UNTUK SOCIAL MEDIA (Open Graph) ========== -->
<meta property="og:title" content="Belajar HTML - Tutorial Lengkap untuk Pemula">
<meta property="og:description" content="Tutorial HTML lengkap dari dasar hingga mahir. Cocok
untuk pemula yang ingin menjadi web developer.">
<meta property="og:image" content="[Link]
<meta property="og:url" content="[Link]
<meta property="og:type" content="website">
<meta property="og:locale" content="id_ID">
Latihan Soal
Soal 1: Meta tag apa yang membuat website responsive di mobile?
A. <meta mobile>
B. <meta viewport> ✓
C. <meta responsive>
D. <meta screen>
Jawaban: B
Jawaban: B
Meta description memberikan deskripsi singkat tentang halaman ke mesin pencari,
yang biasanya ditampilkan di hasil pencarian.
Jawaban: C
Meta tags diletakkan di dalam tag <head> karena berisi informasi tentang dokumen,
bukan konten yang terlihat.
Praktik Langsung
Tugas: Buat halaman website dengan meta tags lengkap untuk:
- SEO (description, keywords, author)
- Social media (Open Graph untuk Facebook)
- Mobile responsive (viewport)
Kode referensi:
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<h2>Proyek Terbaru</h2>
<ul>
<li>Website E-commerce</li>
<li>Aplikasi To-Do List</li>
<li>Portofolio Gallery</li>
</ul>
<footer>
<p>© 2024 Ahmad Wijaya</p>
</footer>
</body>
</html>
MATERI 9: STYLE INLINE
Contoh:
<!DOCTYPE html>
<html>
<head>
<title>Style Inline - Latihan</title>
</head>
<body>
<h1 style="color: #667eea; text-align: center; font-family: Arial;">
Belajar Style Inline
</h1>
<div style="background-color: #f0f0f0; padding: 20px; border-radius: 10px; margin: 20px 0;">
<h2 style="margin-top: 0;">Card dengan Style Inline</h2>
<p style="margin-bottom: 0;">Div ini memiliki background abu-abu, padding, dan sudut
melengkung.</p>
</div>
<button style="background-color: #4CAF50; color: white; padding: 10px 20px; border: none;
border-radius: 5px; cursor: pointer;">
Klik Saya
</button>
<img src="[Link]
style="border: 3px solid #667eea; border-radius: 10px; margin-top: 20px;">
</body>
</html>
Pro Tips
1. Gunakan untuk testing cepat - Coba gaya baru tanpa buat file CSS
2. Hindari untuk produksi - Kecuali email HTML atau situasi khusus
3. Spesifisitas tinggi - Style inline override style dari file CSS
4. JavaScript friendly - Mudah diubah dengan [Link]
javascript
Latihan Soal
Soal 1: Bagaimana cara memberi style inline?
A. Menggunakan tag <style>
B. Atribut style di tag pembuka ✓
C. File CSS terpisah
D. Tidak bisa
Jawaban: B
Style inline ditulis langsung di atribut style pada tag pembuka elemen.
Jawaban: B
Style inline cocok untuk testing cepat, styling unik satu elemen, atau email HTML.
Praktik Langsung
Tugas: Buat kartu produk dengan style inline:
- Container div dengan border, padding, border-radius
- Judul produk dengan warna dan font tertentu
- Harga dengan warna hijau dan ukuran besar
- Tombol beli dengan background warna dan efek hover
Kode referensi:
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Latihan Style Inline - Kartu Produk</title>
</head>
<body style="font-family: 'Segoe UI', Arial, sans-serif; background: #f5f5f5; padding: 20px;">
<div style="max-width: 350px; margin: 0 auto; background: white; border-radius: 15px; overflow:
hidden; box-shadow: 0 4px 8px rgba(0,0,0,0.1);">
</body>
</html>
BAB 5: PROYEK AKHIR
MATERI 10: PROJECT AKHIR - MEMBUAT PROFIL PRIBADI
PROFESIONAL
Tujuan Proyek
Selamat! Anda telah mempelajari semua materi HTML lanjutan. Sekarang saatnya
menggabungkan semuanya menjadi sebuah website profil pribadi yang profesional
dan lengkap.
Spesifikasi Website
Website profil pribadi Anda harus mencakup:
1. Struktur Semantic HTML - Header, nav, main, article, aside, footer
2. Meta Tags lengkap - SEO, Open Graph, viewport
3. Tabel - Untuk menampilkan skill atau jadwal
4. Form - Untuk kontak atau newsletter
5. Audio/Video - Musik latar atau video profil
6. Iframe - Peta lokasi atau video YouTube
7. Karakter Khusus - Simbol copyright, mata uang, dll
8. Style Inline - Untuk beberapa elemen spesifik
9. Div dan Span - Untuk pengelompokan dan styling
10. List (ul/ol) - Untuk pengalaman, pendidikan, dll
<!DOCTYPE html>
<html lang="id">
<head>
<!-- ========== META TAGS ========== -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: #333;
background: #f0f2f5;
}
/* Header */
header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
text-align: center;
padding: 3rem 1rem;
}
header h1 {
font-size: 2.5rem;
margin-bottom: 0.5rem;
}
/* Navigation */
nav {
background: #2c3e50;
padding: 1rem;
text-align: center;
position: sticky;
top: 0;
z-index: 100;
}
nav a {
color: white;
text-decoration: none;
margin: 0 1rem;
padding: 0.5rem 1rem;
border-radius: 5px;
transition: background 0.3s;
}
nav a:hover {
background: #34495e;
}
/* Main Layout */
main {
max-width: 1200px;
margin: 2rem auto;
padding: 0 1rem;
display: grid;
grid-template-columns: 2fr 1fr;
gap: 2rem;
}
/* Article / Cards */
article {
background: white;
border-radius: 15px;
padding: 1.5rem;
margin-bottom: 1.5rem;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
article h2 {
color: #667eea;
margin-bottom: 1rem;
border-bottom: 2px solid #667eea;
padding-bottom: 0.5rem;
}
/* Aside / Sidebar */
aside {
background: white;
border-radius: 15px;
padding: 1.5rem;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
height: fit-content;
}
aside h3 {
color: #667eea;
margin-bottom: 1rem;
border-bottom: 2px solid #667eea;
padding-bottom: 0.5rem;
}
/* Table */
.skill-table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
}
.skill-table th {
background: #667eea;
color: white;
}
/* Form */
.form-group {
margin-bottom: 1rem;
}
.form-group label {
display: block;
margin-bottom: 0.3rem;
font-weight: bold;
}
button {
background: #667eea;
color: white;
border: none;
padding: 0.5rem 1rem;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background: #5a67d8;
}
/* Responsive */
@media (max-width: 768px) {
main {
grid-template-columns: 1fr;
}
}
/* Footer */
footer {
background: #2c3e50;
color: white;
text-align: center;
padding: 1.5rem;
margin-top: 2rem;
}
footer a {
color: white;
text-decoration: none;
}
</style>
</head>
<body>
<div>
<h3>� Portfolio Gallery</h3>
<p>Galeri portofolio interaktif dengan filter kategori dan lightbox preview.</p>
<p><strong>Teknologi:</strong> HTML5, CSS Flexbox, JavaScript, Lightbox</p>
</div>
</article>
</div>
src="[Link]
8677!3d-
6.208670!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x2e69f3e945e34b9d%3A0x5371bf
0fdad786a2!2sMonas!5e0!3m2!1sid!2sid!4v1234567890"
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;"
allowfullscreen=""
loading="lazy">
</iframe>
</div>
Checklist Proyek
Selamat!
Anda telah menyelesaikan HTML Lanjutan: Mastering Intermediate HTML dan
berhasil membuat website profil pribadi yang profesional!
Selamat! Anda sekarang telah menguasai HTML dari dasar hingga tingkat lanjut.
Anda memiliki fondasi yang kuat untuk melanjutkan ke teknologi web lainnya.
Langkah Selanjutnya
1. CSS (Cascading Style Sheets) - Pelajari styling lebih dalam (Flexbox, Grid,
Animations)
2. JavaScript - Buat website interaktif dengan logika pemrograman
3. Responsive Design - Buat website yang bagus di semua device
4. Git & GitHub - Version control untuk proyek profesional
5. Framework - [Link], [Link], atau Angular
Pesan Motivasi
"Kemahiran tidak datang dalam semalam. Setiap ahli pernah menjadi pemula.
Teruslah belajar, teruslah berkarya, dan jangan takut membuat kesalahan. Setiap
error adalah pelajaran berharga."