-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathCharacter Counter
49 lines (49 loc) · 1.17 KB
/
Character Counter
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
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Character Counter</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="counter-container">
<h1>Character Counter</h1>
<textarea id="textInput" placeholder="Start typing..."></textarea>
<p id="charCountDisplay">Characters: 0</p>
</div>
<script src="script.js"></script>
</body>
</html>
CSS:
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.counter-container {
text-align: center;
background-color: #f0f0f0;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
textarea {
width: 100%;
height: 100px;
padding: 10px;
font-size: 16px;
}
p {
font-size: 18px;
margin-top: 10px;
}
JavaScript:
document.getElementById('textInput').addEventListener('input', function() {
const charCount = this.value.length;
document.getElementById('charCountDisplay').textContent = `Characters: ${charCount}`;
});