2 Contoh Penerapan Gaya Gelap di Halaman HTML: Panduan Praktis
mrfdn.com – Gaya gelap, atau gaya hitam, telah menjadi populer dalam desain antarmuka pengguna.
Banyak pengguna yang mengapresiasi opsi ini karena mengurangi kelelahan mata dan meningkatkan kenyamanan saat menggunakan perangkat di malam hari.
Pada artikel ini kita akan membahas bagaimana menerapkan gaya hitam di halaman HTML menggunakan HTML, CSS, dan JavaScript.
Opsi 1: Tanpa #
Dalam contoh pertama ini, kami menggunakan 2 tombol untuk beralih secara manual antara mode terang dan mode gelap.
<!DOCTYPE html>
<html lang="en" theme="dark">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet">
<style>
#darkmode {
background: #222;
color: #eee;
}
</style>
</head>
<body>
<h1>halo raf</h1>
<p>raf</p>
<button onclick="setDarkMode(true)">dark</button>
<button onclick="setDarkMode(false)">light</button>
</body>
<script>
if(localStorage.getItem('theme') == 'dark')
setDarkMode(true)
function setDarkMode(isDark){
if(isDark) {
document.body.setAttribute('id', 'darkmode')
localStorage.setItem('theme', 'dark')
} else {
document.body.setAttribute('id', '')
localStorage.removeItem('theme')
}
}
</script>
</html>
Tip 2 : Dengan kuas#
Pada dokumen HTML berikut, kita cukup menggunakan tombol 1 untuk mengubah karakter dari gelap menjadi terang, dan sebaliknya.
<!DOCTYPE html>
<html lang="en" theme="dark">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet">
<style>
.dark-mode {
background: #222;
color: #eee;
}
</style>
</head>
<body>
<h1>Dark Mode</h1>
<p>jagotekno.com</p>
<button id="toggleButton">Toggle Dark Mode</button>
</body>
<script>
const toggleButton = document.getElementById('toggleButton');
const body = document.body;
toggleButton.addEventListener('click', () => {
body.classList.toggle('dark-mode');
});
</script>
</html>
Akhir#
Menerapkan gaya hitam pada halaman HTML tidaklah sulit.
Dengan menggunakan kombinasi HTML, CSS, dan JavaScript, Anda dapat memberikan opsi yang tepat bagi pengguna Anda.
Pastikan untuk mengintegrasikan elemen hitam ini dengan keseluruhan desain situs web Anda agar sesuai dengan tema yang Anda inginkan.
Jangan lupa untuk menguji tampilan halaman Anda di berbagai perangkat dan browser untuk memastikan konsistensi.
Semoga beruntung
PakarPBN
A Private Blog Network (PBN) is a collection of websites that are controlled by a single individual or organization and used primarily to build backlinks to a “money site” in order to influence its ranking in search engines such as Google. The core idea behind a PBN is based on the importance of backlinks in Google’s ranking algorithm. Since Google views backlinks as signals of authority and trust, some website owners attempt to artificially create these signals through a controlled network of sites.
In a typical PBN setup, the owner acquires expired or aged domains that already have existing authority, backlinks, and history. These domains are rebuilt with new content and hosted separately, often using different IP addresses, hosting providers, themes, and ownership details to make them appear unrelated. Within the content published on these sites, links are strategically placed that point to the main website the owner wants to rank higher. By doing this, the owner attempts to pass link equity (also known as “link juice”) from the PBN sites to the target website.
The purpose of a PBN is to give the impression that the target website is naturally earning links from multiple independent sources. If done effectively, this can temporarily improve keyword rankings, increase organic visibility, and drive more traffic from search results.