forked from Hardik1264/Web_Development
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dark-light-mode.html
53 lines (46 loc) · 1.38 KB
/
dark-light-mode.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Light/Dark mode practice Website</title>
<style>
body{
color: black;
background-color: white;
text-align: center;
align-items: center;
}
.dark-mode{
background-color: black;
color:white;
}
.light-mode{
background-color: white;
color: black;
}
</style>
</head>
<body>
<h1>Light and Dark Mode</h1>
<p>This is a sample Website Text.Dark Mode Websites using Html CSS & Javascript</p>
<p id="text">Dark Mode is OFF</p>
<button onclick="darkmode()">Dark Mode</button>
<button onclick="lightmode()">Light Mode</button>
<script>
function darkmode(){
var ele = document.body;
var content = document.getElementById("text");
ele.className = "dark-mode";
content.innerText = "Dark Mode is ON";
}
function lightmode(){
var ele = document.body;
var content = document.getElementById("text");
ele.className = "light-mode";
content.innerText = "Dark Mode is OFF";
}
</script>
</body>
</html>