Menulis Semantik HTML

Yustina Yasin
7 min readDec 23, 2022

Saat ini saya sedang belajar frontend development berdasarkan panduan dari roadmap berikut. Saya mengulang kembali perjalanan saya dari awal dan berusaha untuk lebih mendalami setiap section. Pada section HTML sendiri terdapat sub bab semantik HTML. Semantik HTML ditandai sebagai sub bab yang tidak perlu dipelajar secara terburu-buru oleh penulis. Namun, semantik HTML cukup penting untuk dipelajari.

Semantik HTML adalah kode-kode HTML yang terstruktur. Terstruktur di sini berarti setiap elemen bisa diidentifikasi dengan mudah. Contohnya seperti elemen<h1> lebih mudah dikenali sebagai judul dibanding dengan elemen<div> yang memiliki banyak fungsi. Semantik HTML juga berperan dalam ranking search engine.

Kita akan mencoba meninjau code lama saya dari challenge frontendmentor. Berikut adalah code HTML-nya:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- displays site properly based on user's device -->

<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">

<title>Frontend Mentor | [Challenge Name Here]</title>

<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
<!-- <style>
.attribution { font-size: 11px; text-align: center; }
.attribution a { color: hsl(228, 45%, 44%); }
</style> -->

<link rel="stylesheet" href="style.css">
</head>
<body>
<main>
<div class="testimonial first-testimonial">
<img class="bg" src="images/bg-pattern-quotation.svg" alt="quote">
<div class="identity">
<img class="photo" src="images/image-daniel.jpg" alt="daniel">
<div class="information">
<div class="full-name">Daniel Clifford</div>
<div class="status">Verified Graduate</div>
</div>
</div>
<h2 class="conclusion">I received a job offer mid-course, and the subjects I learned were current, if not more so,
in the company I joined. I honestly feel I got every penny’s worth.</h2>
<div class="description"> “ I was an EMT for many years before I joined the bootcamp. I’ve been looking to make a
transition and have heard some people who had an amazing experience here. I signed up
for the free intro course and found it incredibly fun! I enrolled shortly thereafter.
The next 12 weeks was the best - and most grueling - time of my life. Since completing
the course, I’ve successfully switched careers, working as a Software Engineer at a VR startup. ”</div>
</div>
<div class="testimonial second-testimonial">
<div class="identity">
<img class="photo" src="images/image-jonathan.jpg" alt="image-jonathan.jpg">
<div class="information">
<div class="full-name">Jonathan Walters</div>
<div class="status">Verified Graduate</div>
</div>
</div>
<h2 class="conclusion">The team was very supportive and kept me motivated</h2>
<div class="description">“ I started as a total newbie with virtually no coding skills. I now work as a mobile engineer
for a big company. This was one of the best investments I’ve made in myself. ”</div>
</div>
<div class="testimonial third-testimonial">
<div class="identity">
<img class="photo" src="images/image-jeanette.jpg" alt="jeimage-jeanette.jpg">
<div class="information">
<div class="full-name">Jeanette Harmon</div>
<div class="status">Verified Graduate</div>
</div>
</div>
<h2 class="conclusion">An overall wonderful and rewarding experience</h2>
<div class="description">“ Thank you for the wonderful experience! I now have a job I really enjoy, and make a good living
while doing something I love. ”</div>
</div>
<div class="testimonial fourth-testimonial">
<div class="identity">
<img class="photo" src="images/image-patrick.jpg" alt="paimage-patrick.jpg">
<div class="information">
<div class="full-name">Patrick Abrams</div>
<div class="status">Verified Graduate</div>
</div>
</div>
<h2 class="conclusion">Awesome teaching support from TAs who did the bootcamp themselves. Getting guidance from them and
learning from their experiences was easy.</h2>
<div class="description"> “ The staff seem genuinely concerned about my progress which I find really refreshing. The program
gave me the confidence necessary to be able to go out in the world and present myself as a capable
junior developer. The standard is above the rest. You will get the personal attention you need from
an incredible community of smart and amazing people. ”
</div>
</div>
<div class="testimonial fifth-testimonial">
<div class="identity">
<img class="photo" src="images/image-kira.jpg" alt="kimage-kira.jpg">
<div class="information">
<div class="full-name">Kira Whittle</div>
<div class="status">Verified Graduate</div>
</div>
</div>
<h2 class="conclusion">Such a life-changing experience. Highly recommended!</h2>
<div class="description"> “ Before joining the bootcamp, I’ve never written a line of code. I needed some structure from
professionals who can help me learn programming step by step. I was encouraged to enroll by a former
student of theirs who can only say wonderful things about the program. The entire curriculum and staff
did not disappoint. They were very hands-on and I never had to wait long for assistance. The agile team
project, in particular, was outstanding. It took my learning to the next level in a way that no tutorial
could ever have. In fact, I’ve often referred to it during interviews as an example of my developent
experience. It certainly helped me land a job as a full-stack developer after receiving multiple offers.
100% recommend! ”
</div>
</div>
</main>

<div class="attribution">
Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank">Frontend Mentor</a>.
Coded by <a href="https://github.com/yustinayasin">Yustina Yasin</a>.
</div>
</body>
</html>

Berdasarkan codes di atas penggunaan elemen<div> terlalu banyak membuat kode tidak mudah dibaca, kita perlu membaca class terlebih dahulu untuk mengetahui bagian mana yang merupakan title dan content. Maka dari itu semua elemen<div> yang ada perlu ditinjau penggunaanya dan diganti dengan elemen yang lebih deskriptif diantaranya:

  1. Elemen<div> dengan class testimonial, identity, dan information diganti dengan elemen <section> yang lebih cocok untuk membagi main content menjadi beberapa bagian
  2. Elemen<div> dengan class description diganti dengan elemen <p> karena merupakan sebuah paragraf deskripsi
  3. Elemen<div di akhir codes lebih cocok diganti menggunakan elemen<footer> yang tidak masuk ke main content namun masih berhubungan
  4. Elemen <div> di dalam class information diganti dengan elemen <p>
  5. Ubah penggunaan &, <, >, “, ` menggunakan named character references yang di-support oleh HTML untuk menghindari bug
  6. Gunakan numeric caracter references &#xA0; untuk spasi diantara angka dan kata
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- displays site properly based on user's device -->

<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">

<title>Frontend Mentor | [Challenge Name Here]</title>

<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
<!-- <style>
.attribution { font-size: 11px; text-align: center; }
.attribution a { color: hsl(228, 45%, 44%); }
</style> -->

<link rel="stylesheet" href="style.css">
</head>
<body>
<main>
<section class="testimonial first-testimonial">
<img class="bg" src="images/bg-pattern-quotation.svg" alt="quote">
<section class="identity">
<img class="photo" src="images/image-daniel.jpg" alt="daniel">
<section class="information">
<p class="full-name">Daniel Clifford</p>
<p class="status">Verified Graduate</p>
</section>
</section>
<h2 class="conclusion">I received a job offer mid-course, and the subjects I learned were current, if not more so,
in the company I joined. I honestly feel I got every penny&rsquo;s worth.</h2>
<p class="description">&quot;I was an EMT for many years before I joined the bootcamp. I&rsquo;ve been looking to make a
transition and have heard some people who had an amazing experience here. I signed up
for the free intro course and found it incredibly fun! I enrolled shortly thereafter.
The next 12 weeks was the best - and most grueling - time of my life. Since completing
the course, I&rsquo;ve successfully switched careers, working as a Software Engineer at a VR startup.&quot;
</p>
</section>
<section class="testimonial second-testimonial">
<section class="identity">
<img class="photo" src="images/image-jonathan.jpg" alt="image-jonathan.jpg">
<section class="information">
<p class="full-name">Jonathan Walters</p>
<p class="status">Verified Graduate</p>
</section>
</section>
<h2 class="conclusion">The team was very supportive and kept me motivated</h2>
<p class="description">&quot;I started as a total newbie with virtually no coding skills. I now work as a mobile engineer
for a big company. This was one of the best investments I&rsquo;ve made in myself.&quot;
</p>
</section>
<section class="testimonial third-testimonial">
<section class="identity">
<img class="photo" src="images/image-jeanette.jpg" alt="jeimage-jeanette.jpg">
<section class="information">
<p class="full-name">Jeanette Harmon</p>
<p class="status">Verified Graduate</p>
</section>
</section>
<h2 class="conclusion">An overall wonderful and rewarding experience</h2>
<p class="description">&quot;Thank you for the wonderful experience! I now have a job I really enjoy, and make a good living
while doing something I love.&quot;
</p>
</section>
<section class="testimonial fourth-testimonial">
<section class="identity">
<img class="photo" src="images/image-patrick.jpg" alt="paimage-patrick.jpg">
<section class="information">
<p class="full-name">Patrick Abrams</p>
<p class="status">Verified Graduate</p>
</section>
</section>
<h2 class="conclusion">Awesome teaching support from TAs who did the bootcamp themselves. Getting guidance from them and
learning from their experiences was easy.</h2>
<p class="description">&quot;The staff seem genuinely concerned about my progress which I find really refreshing. The program
gave me the confidence necessary to be able to go out in the world and present myself as a capable
junior developer. The standard is above the rest. You will get the personal attention you need from
an incredible community of smart and amazing people.&quot;
</p>
</section>
<section class="testimonial fifth-testimonial">
<section class="identity">
<img class="photo" src="images/image-kira.jpg" alt="kimage-kira.jpg">
<section class="information">
<p class="full-name">Kira Whittle</p>
<p class="status">Verified Graduate</p>
</section>
</section>
<h2 class="conclusion">Such a life-changing experience. Highly recommended!</h2>
<p class="description">&quot;Before joining the bootcamp, I&rsquo;ve never written a line of code. I needed some structure from
professionals who can help me learn programming step by step. I was encouraged to enroll by a former
student of theirs who can only say wonderful things about the program. The entire curriculum and staff
did not disappoint. They were very hands-on and I never had to wait long for assistance. The agile team
project, in particular, was outstanding. It took my learning to the next level in a way that no tutorial
could ever have. In fact, I&rsquo;ve often referred to it during interviews as an example of my developent
experience. It certainly helped me land a job as a full-stack developer after receiving multiple offers.
100% recommend!&quot;
</p>
</section>
</main>

<footer class="attribution">
Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank">Frontend Mentor</a>.
Coded by <a href="https://github.com/yustinayasin">Yustina Yasin</a>.
</footer>
</body>
</html>

Sekian bedah kode lama dari saya semoga bermanfaat, jika ada saran penulisan kode yang lebih baik silahkan berkomentar di bawah.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response