<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.rating {
unicode-bidi: bidi-override;
direction: rtl;
text-align: center;
position: relative;
}
.star {
display: inline-block;
margin: 0 4px;
cursor: pointer;
}
.star:before {
content: '\2605'; /* Unicode character for a star */
font-size: 24px;
color: #ccc;
}
.star.active:before,
.star:hover:before {
color: #ffcc00;
}
</style>
</head>
<body>
<div class="rating">
<div class="star" onclick="rate(5)"></div>
<div class="star" onclick="rate(4)"></div>
<div class="star" onclick="rate(3)"></div>
<div class="star" onclick="rate(2)"></div>
<div class="star" onclick="rate(1)"></div>
</div>
<script>
let currentRating = 0;
function rate(stars) {
currentRating = stars;
highlightStars();
}
function highlightStars() {
for (let i = 1; i <= 5; i++) {
const star = document.querySelector(`#rating .star:nth-child(${i})`);
star.classList.toggle('active', i <= currentRating);
}
}
</script>
</body>
</html>