A simple and interactive Tic-Tac-Toe web game built using HTML, CSS, and JavaScript.
The project provides a clean browser-based gaming experience while demonstrating fundamental concepts of frontend web development, JavaScript game logic, DOM manipulation, and user interaction.
๐ Repository: https://github.com/Atibayounus/TIC-TAC-TOE.git
Tic-Tac-Toe is a classic two-player game played on a 3 ร 3 grid.
Players take turns placing their symbols:
- โ Player X
- โญ Player O
The objective is to get three matching symbols in a row, column, or diagonal before the opponent.
This project was built to practice HTML structure, CSS styling, and JavaScript logic while creating a functional interactive web application.
- ๐ฎ Two-player gameplay
- โ X and O turns
- ๐งฉ Interactive 3 ร 3 game board
- ๐ Automatic winner detection
- ๐ค Draw detection
- ๐ Restart / New Game functionality
- โก Instant game updates
- ๐ฑ๏ธ Click-based interaction
- ๐ฑ Clean and responsive interface
- ๐ Runs directly in the browser
Used to create the structure of the game:
- Game board
- Player information
- Buttons
- Game status
Used to design the interface:
- Game board layout
- Styling
- Spacing
- Typography
- Buttons
- Responsive design
- Hover effects
Used to implement the game functionality:
- Player turns
- Click events
- Game state
- Winner detection
- Draw detection
- Reset functionality
- DOM manipulation
HTML provides the basic structure of the application.
<div class="game-board">
<div class="cell"></div>
<div class="cell"></div>
<div class="cell"></div>
</div>CSS controls the visual appearance and layout of the game.
The board can be created using CSS Grid:
.game-board {
display: grid;
grid-template-columns: repeat(3, 1fr);
}JavaScript handles the actual game logic.
For example, click events can be used to detect when a player selects a cell:
cell.addEventListener("click", handleClick);The program then updates the board and checks whether a player has won.
There are 8 possible winning combinations in Tic-Tac-Toe:
X | X | X
---------
| |
---------
| |
X | |
X | |
X | |
X | |
| X |
| | X
JavaScript checks these combinations after each move to determine the winner.
- Open the game in your browser.
- Player X starts the game.
- Click an empty cell.
- Player O takes the next turn.
- Continue taking turns.
- Get three matching symbols in a row, column, or diagonal to win.
- If all cells are filled without a winner, the game ends in a draw.
- Use the restart button to play again.
TIC-TAC-TOE/
โ
โโโ index.html
โโโ style.css
โโโ script.js
โ
โโโ README.md
No installation or external dependencies are required.
git clone https://github.com/Atibayounus/TIC-TAC-TOE.gitcd TIC-TAC-TOESimply open:
index.html
in any modern web browser.
You can also use VS Code Live Server for development.
Start Game
โ
Player X Turn
โ
Select Cell
โ
Update Board
โ
Check Winner
โ
Check Draw
โ
Player O Turn
โ
Select Cell
โ
Update Board
โ
Check Winner
โ
Check Draw
โ
Game Over / Continue
The interface is designed to work across different screen sizes, including:
- ๐ป Desktop
- ๐ป Laptop
- ๐ฑ Mobile
- ๐ฒ Tablet
CSS media queries can be used to adjust the layout for smaller screens.
Building this project helped me practice:
- HTML5 structure
- CSS3 styling
- CSS Grid
- JavaScript fundamentals
- DOM manipulation
- Event listeners
- Arrays
- Functions
- Conditional statements
- Game state management
- Winner detection
- User interaction
- Debugging
Possible improvements include:
- ๐ค Add a computer/AI opponent
- ๐๏ธ Add difficulty levels
- ๐ Add score tracking
- ๐ค Add player names
- ๐ Add sound effects
- โจ Add animations
- ๐ Add theme switching
- ๐ Add match statistics
- ๐พ Store scores using Local Storage
Atiba Dar
๐ Computer Science Student ๐ซ University of Gujrat, Pakistan ๐ป Frontend Developer & Programming Learner
๐ @Atibayounus
If you like this project, consider giving the repository a โญ on GitHub.
Built with HTML, CSS & JavaScript โ one move at a time. ๐ฎ๐ป


