<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
meta
name
=
"viewport"
content
=
"width=device-width, initial-scale=1.0"
>
<
title
>Card with Like/Dislike Toggle</
title
>
<
link
rel
=
"stylesheet"
href
=
<
style
>
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
.card {
width: 300px;
border: 1px solid #ccc;
border-radius: 8px;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
margin-bottom: 20px;
display: flex;
flex-direction: column;
align-items: center;
}
.like-btn {
cursor: pointer;
transition: color 0.3s ease;
}
.like-btn i {
font-size: 36px;
}
.like-btn.active i {
color: #4CAF50;
/* Green color for active state */
}
</
style
>
</
head
>
<
body
>
<
div
class
=
"card"
>
<
h2
>GeeksforGeeks</
h2
>
<
p
>A computer Science Portal for Geeks</
p
>
<
div
class
=
"like-btn"
onclick
=
"toggleLike()"
>
<
i
class
=
"fas fa-thumbs-up"
></
i
>
</
div
>
</
div
>
<
script
>
let likeBtn = document.querySelector('.like-btn');
function toggleLike() {
likeBtn.classList.toggle('active');
// Toggle Font Awesome class for the
// thumbs-up and thumbs-down icons
if (likeBtn.classList.contains('active')) {
likeBtn.innerHTML =
'<
i
class
=
"fas fa-thumbs-down"
></
i
>';
} else {
likeBtn.innerHTML =
'<
i
class
=
"fas fa-thumbs-up"
></
i
>';
}
}
</
script
>
</
body
>
</
html
>