Mengenal HTML Boilerplate

Halo teman-teman!

Kali ini, kita akan belajar tentang HTML Boilerplate, yaitu kerangka dasar yang menjadi struktur utama file HTML. Ibarat menulis surat, HTML Boilerplate ini seperti format standar: ada bagian pembuka, isi, dan penutup. Yuk, kita bahas langkah demi langkah!


Apa Itu HTML Boilerplate?

HTML Boilerplate adalah template awal yang digunakan untuk setiap file HTML. Ini memastikan bahwa kode HTML kita punya struktur yang rapi dan standar, sehingga browser bisa membaca dan menampilkan website kita dengan benar.


Komponen Dasar HTML Boilerplate

HTML Boilerplate terdiri dari beberapa bagian penting:

1. Deklarasi Doctype

Baris pertama di setiap file HTML adalah deklarasi Doctype. Ini memberi tahu browser bahwa kita menggunakan HTML5. Formatnya seperti ini:

<!DOCTYPE html>

2. Elemen <html>

Semua elemen HTML ada di dalam elemen <html>. Ini adalah akar dari dokumen HTML. Kita juga bisa menambahkan atribut lang untuk menunjukkan bahasa utama situs. Misalnya, jika situs dalam bahasa Indonesia:

<html lang="id">

3. Elemen <head>

Bagian ini berisi informasi tentang website yang tidak terlihat langsung oleh pengguna. Contohnya:

  • <meta charset="UTF-8">: Menentukan karakter yang digunakan. UTF-8 mendukung banyak karakter, termasuk emoji.
  • <title>: Menentukan judul website yang tampil di tab browser.
    <head>
      <meta charset="UTF-8">
      <title>Website Saya</title>
    </head>
    

4. Elemen <body>

Semua konten website, seperti teks, gambar, dan link, diletakkan di dalam elemen <body>. Misalnya:

<body>
  <h1>Halo Dunia!</h1>
  <p>Selamat datang di website saya.</p>
</body>

Struktur Lengkap HTML Boilerplate

Berikut adalah contoh lengkap HTML Boilerplate:

<!DOCTYPE html>
<html lang="id">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Website Saya</title>
</head>
<body>
  <h1>Halo Dunia!</h1>
  <p>Selamat datang di website saya.</p>
</body>
</html>

Tips Penting: Shortcut Boilerplate di VS Code

Kamu tidak perlu mengetik semuanya secara manual setiap kali membuat file HTML baru. Di VS Code, cukup:

  1. Buat file baru dengan ekstensi .html.
  2. Ketik tanda seru ! lalu tekan Enter.
    VS Code akan otomatis men-generate HTML Boilerplate untukmu!

Latihan: Membuat Burger dengan HTML

Sekarang, saatnya berlatih! Bayangkan kita membuat sebuah burger, tapi dalam bentuk HTML. Gunakan elemen HTML untuk mewakili bagian-bagian burger:

Contoh:

<!DOCTYPE html>
<html lang="id">
<head>
  <meta charset="UTF-8">
  <title>Burger Saya</title>
</head>
<body>
  <div class="burger">
    <div class="bun-top">Roti Atas</div>
    <div class="lettuce">Selada</div>
    <div class="meat">Daging</div>
    <div class="bun-bottom">Roti Bawah</div>
  </div>
</body>
</html>

Coba buat burger versimu sendiri! Tambahkan elemen seperti keju, tomat, atau saus, dan pastikan menggunakan indentasi yang rapi agar kodenya mudah dibaca.


Kesimpulan

HTML Boilerplate adalah fondasi setiap website. Dengan memahami strukturnya, kamu sudah siap membangun halaman web yang lebih kompleks. Jangan lupa latihan membuat burger HTML-mu sendiri, ya!

Selanjutnya, kita akan belajar tentang nesting dan bagaimana menjaga kode tetap rapi dengan indentasi yang baik. Sampai jumpa di pelajaran berikutnya! 

Comments

Postingan Populer

Image

Superingan is a Blogger template designed with simplicity and functionality in mind, offering a clean and user-friendly platform for professional websites. This theme is perfect for various website types, including personal blogs, online magazines, news websites, and portfolios. Features: Responsive Design: Your website will look its best across all devices, from desktops and laptops to tablets and smartphones. Customizable Colors: Easily change the template's colors to match your branding or preferences. Custom Headers: Upload your own header image to add a personal touch to your website. Custom Menus: Create and manage your website's navigation menus with ease. Widget Areas: Add widgets to display additional content and features on your website's sidebar. Clean HTML & CSS Code: The template is built with clean and well-structured code, making it easy to learn and customize further. Superingan is an ideal choice for those seeking a professional website with a sim...

Image

If you’ve ever struggled to align elements neatly in CSS—or tried to make a layout look good on both desktop and mobile— Flexbox CSS is your new best friend. Short for "Flexible Box Layout," Flexbox is a layout module in CSS3 that provides an efficient way to distribute space and align items in a container, even when their sizes are dynamic. In this flexbox tutorial for beginners , we’ll guide you step-by-step through what Flexbox is, why it’s essential for responsive design, and how to use it to build clean, adaptable layouts. By the end of this guide, you’ll be able to use Flexbox confidently to build elements like navigation bars, feature sections, and even a CSS flexbox pricing table example . Whether you're a self-taught developer, a student, or someone shifting into a front-end career, Flexbox will become one of your most powerful tools in building responsive, user-friendly websites. Before diving into the code, if you're not yet familiar with CSS fundamenta...

Hello friends, how are you doing? If you own a blog or website and want to earn more revenue through Google AdSense, you’ve come to the right place. In this comprehensive article, we’re going to explore a variety of methods to increase your Cost Per Click (CPC) and Click-Through Rate (CTR), two crucial metrics that greatly influence how much you earn from ads on your blog. We will dig into how to make your blog more appealing to advertisers so that the monetary value of each ad click (CPC) goes up, and the percentage of people who click on your ads (CTR) also rises. We’ll discuss why these two factors matter, how to optimize your content, strategies for choosing the right topics, and how to place ads strategically. We’ll also highlight the importance of SEO so that your blog becomes easier for people to find through search engines. With increased visibility in search results, you can attract more visitors—and with more visitors, your opportunities for higher ad clicks multiply, which ...