Rock Paper Scissor Game using Tailwind CSS & JavaScript Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Rock Paper Scissors Game is a web-based game that simulates the classic hand game. It allows users to play against the computer by choosing between rock, paper, or scissors. The game is built using Tailwind CSS, a utility-first CSS framework, which ensures a responsive and visual design. Approach to create Rock, Paper, Scissors Game:Begin with a basic HTML structure, including the <!DOCTYPE html> declaration, <html>, <head>, and <body> tags. Import external resources like Tailwind CSS for styling.Create a container div with Tailwind CSS classes for styling. Inside the container, include elements for the game title, buttons for rock, paper, and scissors, and a result container to display the player's choice, computer's choice, scores, and the game result.Use JavaScript to handle the game logic. Define a function to play a round of the game, which takes the player's and computer's choices as arguments and returns the result of the round. Use event listeners to trigger the function when the player clicks on a button.Update the content of the result container with the player's and computer's choices, the game result, and the updated scores after each round.Use Tailwind CSS classes to style the game container, buttons, and result container. Customize the colors, fonts, and layout to create an appealing visual design for the game.Example: Implementation to design rock paper scissor game. HTML <!DOCTYPE html> <html lang="en"> <head> <title>Rock Paper Scissors</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href= "https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"> </head> <body class="bg-gray-100"> <div class="game-container border-green-500 max-w-md mx-auto text-center bg-gray-100 rounded-lg shadow-md border-2 border-green-500 p-8 mt-20"> <h1 class="text-3xl font-semibold mb-4"> Rock Paper Scissors </h1> <div class="button-container"> <button class="btn bg-blue-500 text-white font-semibold px-4 py-2 rounded mr-2" id="rock"> Rock </button> <button class="btn bg-blue-500 text-white font-semibold px-4 py-2 rounded mr-2" id="paper"> Paper </button> <button class="btn bg-blue-500 text-white font-semibold px-4 py-2 rounded" id="scissors"> Scissors </button> </div> <div class="result-container flex flex-col justify-center mt-10"> <p class="font-semibold"> Your Choice: <span id="playerChoice"></span> </p> <p class="font-semibold"> Computer's Choice: <span id="computerChoice"></span> </p> <p class="font-semibold"> Your Score: <span id="playerScore">0</span> </p> <p class="font-semibold"> Computer Score: <span id="computerScore">0</span> </p> <p class="result-text" id="result"></p> </div> </div> <script> let playerScore = 0; let computerScore = 0; const playerScoreDisplay = document.getElementById('playerScore'); const computerScoreDisplay = document.getElementById('computerScore'); const playerChoiceDisplay = document.getElementById('playerChoice'); const computerChoiceDisplay = document.getElementById('computerChoice'); const buttons = document.querySelectorAll('.btn'); const choices = ['rock', 'paper', 'scissors']; buttons.forEach(button => { button.addEventListener('click', () => { const playerChoice = button.id; const computerChoice = choices[Math.floor(Math.random() * choices.length)]; playerChoiceDisplay.textContent = playerChoice.charAt(0).toUpperCase() + playerChoice.slice(1); computerChoiceDisplay.textContent = computerChoice.charAt(0).toUpperCase() + computerChoice.slice(1); const result = playRound(playerChoice, computerChoice); document.getElementById('result').innerText = result; playerScoreDisplay.textContent = playerScore; computerScoreDisplay.textContent = computerScore; }); }); function playRound(playerChoice, computerChoice) { if (playerChoice === computerChoice) { return "It's a tie!"; } else if ( (playerChoice === 'rock' && computerChoice === 'scissors') || (playerChoice === 'paper' && computerChoice === 'rock') || (playerChoice === 'scissors' && computerChoice === 'paper') ) { playerScore++; return 'You win!'; } else { computerScore++; return 'Computer wins!'; } } </script> </body> </html> Output: Create Quiz Comment S subramanyasmgm Follow 0 Improve S subramanyasmgm Follow 0 Improve Article Tags : JavaScript Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like