The content on this website, including videos and code examples, is for educational purposes only. All demonstrations and designs are fictional and created to illustrate coding techniques. Any resemblance to existing websites or brands is purely coincidental.
The creators and administrators of this website do not claim ownership or affiliation with any existing websites or companies. Users are encouraged to use the information responsibly for learning purposes. Liability for any misuse of the content provided is not accepted.
Below is the html code for this video.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tic Tac Toe Game</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Tic Tac Toe</h1>
<div class="tic-tac-toe-board">
<input type="radio" id="b1-1-1" class="player-1 left first-column top first-row first-diagonal t-1">
<label for="b1-1-1" class="t-1"></label>
<input type="radio" id="b1-1-2" class="player-1 middle second-column top first-row t-1">
<label for="b1-1-2" class="t-1"></label>
<input type="radio" id="b1-1-3" class="player-1 right third-column top first-row second-diagonal t-1">
<label for="b1-1-3" class="t-1"></label>
<input type="radio" id="b1-2-1" class="player-1 left first-column center second-row t-1">
<label for="b1-2-1" class="t-1"></label>
<input type="radio" id="b1-2-2"
class="player-1 middle second-column center second-row first-diagonal second-diagonal t-1">
<label for="b1-2-2" class="t-1"></label>
<input type="radio" id="b1-2-3" class="player-1 right third-column center second-row t-1">
<label for="b1-2-3" class="t-1"></label>
<input type="radio" id="b1-3-1" class="player-1 left first-column bottom third-row second-diagonal t-1">
<label for="b1-3-1" class="t-1"></label>
<input type="radio" id="b1-3-2" class="player-1 middle second-column bottom third-row t-1">
<label for="b1-3-2" class="t-1"></label>
<input type="radio" id="b1-3-3" class="player-1 right third-column bottom third-row first-diagonal t-1">
<label for="b1-3-3" class="t-1"></label>
<input type="radio" id="b2-1-1" class="player-2 left first-column top first-row first-diagonal t-2">
<label for="b2-1-1" class="t-2"></label>
<input type="radio" id="b2-1-2" class="player-2 middle second-column top first-row t-2">
<label for="b2-1-2" class="t-2"></label>
<input type="radio" id="b2-1-3" class="player-2 right third-column top first-row second-diagonal t-2">
<label for="b2-1-3" class="t-2"></label>
<input type="radio" id="b2-2-1" class="player-2 left first-column center second-row t-2">
<label for="b2-2-1" class="t-2"></label>
<input type="radio" id="b2-2-2"
class="player-2 middle second-column center second-row first-diagonal second-diagonal t-2">
<label for="b2-2-2" class="t-2"></label>
<input type="radio" id="b2-2-3" class="player-2 right third-column center second-row t-2">
<label for="b2-2-3" class="t-2"></label>
<input type="radio" id="b2-3-1" class="player-2 left first-column bottom third-row second-diagonal t-2">
<label for="b2-3-1" class="t-2"></label>
<input type="radio" id="b2-3-2" class="player-2 middle second-column bottom third-row t-2">
<label for="b2-3-2" class="t-2"></label>
<input type="radio" id="b2-3-3" class="player-2 right third-column bottom third-row first-diagonal t-2">
<label for="b2-3-3" class="t-2"></label>
<input type="radio" id="b3-1-1" class="player-1 left first-column top first-row first-diagonal t-3">
<label for="b3-1-1" class="t-3"></label>
<input type="radio" id="b3-1-2" class="player-1 middle second-column top first-row t-3">
<label for="b3-1-2" class="t-3"></label>
<input type="radio" id="b3-1-3" class="player-1 right third-column top first-row second-diagonal t-3">
<label for="b3-1-3" class="t-3"></label>
<input type="radio" id="b3-2-1" class="player-1 left first-column center second-row t-3">
<label for="b3-2-1" class="t-3"></label>
<input type="radio" id="b3-2-2"
class="player-1 middle second-column center second-row first-diagonal second-diagonal t-3">
<label for="b3-2-2" class="t-3"></label>
<input type="radio" id="b3-2-3" class="player-1 right third-column center second-row t-3">
<label for="b3-2-3" class="t-3"></label>
<input type="radio" id="b3-3-1" class="player-1 left first-column bottom third-row second-diagonal t-3">
<label for="b3-3-1" class="t-3"></label>
<input type="radio" id="b3-3-2" class="player-1 middle second-column bottom third-row t-3">
<label for="b3-3-2" class="t-3"></label>
<input type="radio" id="b3-3-3" class="player-1 right third-column bottom third-row first-diagonal t-3">
<label for="b3-3-3" class="t-3"></label>
<input type="radio" id="b4-1-1" class="player-2 left first-column top first-row first-diagonal t-4">
<label for="b4-1-1" class="t-4"></label>
<input type="radio" id="b4-1-2" class="player-2 middle second-column top first-row t-4">
<label for="b4-1-2" class="t-4"></label>
<input type="radio" id="b4-1-3" class="player-2 right third-column top first-row second-diagonal t-4">
<label for="b4-1-3" class="t-4"></label>
<input type="radio" id="b4-2-1" class="player-2 left first-column center second-row t-4">
<label for="b4-2-1" class="t-4"></label>
<input type="radio" id="b4-2-2"
class="player-2 middle second-column center second-row first-diagonal second-diagonal t-4">
<label for="b4-2-2" class="t-4"></label>
<input type="radio" id="b4-2-3" class="player-2 right third-column center second-row t-4">
<label for="b4-2-3" class="t-4"></label>
<input type="radio" id="b4-3-1" class="player-2 left first-column bottom third-row second-diagonal t-4">
<label for="b4-3-1" class="t-4"></label>
<input type="radio" id="b4-3-2" class="player-2 middle second-column bottom third-row t-4">
<label for="b4-3-2" class="t-4"></label>
<input type="radio" id="b4-3-3" class="player-2 right third-column bottom third-row first-diagonal t-4">
<label for="b4-3-3" class="t-4"></label>
<input type="radio" id="b5-1-1" class="player-1 left first-column top first-row first-diagonal t-5">
<label for="b5-1-1" class="t-5"></label>
<input type="radio" id="b5-1-2" class="player-1 middle second-column top first-row t-5">
<label for="b5-1-2" class="t-5"></label>
<input type="radio" id="b5-1-3" class="player-1 right third-column top first-row second-diagonal t-5">
<label for="b5-1-3" class="t-5"></label>
<input type="radio" id="b5-2-1" class="player-1 left first-column center second-row t-5">
<label for="b5-2-1" class="t-5"></label>
<input type="radio" id="b5-2-2"
class="player-1 middle second-column center second-row first-diagonal second-diagonal t-5">
<label for="b5-2-2" class="t-5"></label>
<input type="radio" id="b5-2-3" class="player-1 right third-column center second-row t-5">
<label for="b5-2-3" class="t-5"></label>
<input type="radio" id="b5-3-1" class="player-1 left first-column bottom third-row second-diagonal t-5">
<label for="b5-3-1" class="t-5"></label>
<input type="radio" id="b5-3-2" class="player-1 middle second-column bottom third-row t-5">
<label for="b5-3-2" class="t-5"></label>
<input type="radio" id="b5-3-3" class="player-1 right third-column bottom third-row first-diagonal t-5">
<label for="b5-3-3" class="t-5"></label>
<input type="radio" id="b6-1-1" class="player-2 left first-column top first-row first-diagonal t-6">
<label for="b6-1-1" class="t-6"></label>
<input type="radio" id="b6-1-2" class="player-2 middle second-column top first-row t-6">
<label for="b6-1-2" class="t-6"></label>
<input type="radio" id="b6-1-3" class="player-2 right third-column top first-row second-diagonal t-6">
<label for="b6-1-3" class="t-6"></label>
<input type="radio" id="b6-2-1" class="player-2 left first-column center second-row t-6">
<label for="b6-2-1" class="t-6"></label>
<input type="radio" id="b6-2-2"
class="player-2 middle second-column center second-row first-diagonal second-diagonal t-6">
<label for="b6-2-2" class="t-6"></label>
<input type="radio" id="b6-2-3" class="player-2 right third-column center second-row t-6">
<label for="b6-2-3" class="t-6"></label>
<input type="radio" id="b6-3-1" class="player-2 left first-column bottom third-row second-diagonal t-6">
<label for="b6-3-1" class="t-6"></label>
<input type="radio" id="b6-3-2" class="player-2 middle second-column bottom third-row t-6">
<label for="b6-3-2" class="t-6"></label>
<input type="radio" id="b6-3-3" class="player-2 right third-column bottom third-row first-diagonal t-6">
<label for="b6-3-3" class="t-6"></label>
<input type="radio" id="b7-1-1" class="player-1 left first-column top first-row first-diagonal t-7">
<label for="b7-1-1" class="t-7"></label>
<input type="radio" id="b7-1-2" class="player-1 middle second-column top first-row t-7">
<label for="b7-1-2" class="t-7"></label>
<input type="radio" id="b7-1-3" class="player-1 right third-column top first-row second-diagonal t-7">
<label for="b7-1-3" class="t-7"></label>
<input type="radio" id="b7-2-1" class="player-1 left first-column center second-row t-7">
<label for="b7-2-1" class="t-7"></label>
<input type="radio" id="b7-2-2"
class="player-1 middle second-column center second-row first-diagonal second-diagonal t-7">
<label for="b7-2-2" class="t-7"></label>
<input type="radio" id="b7-2-3" class="player-1 right third-column center second-row t-7">
<label for="b7-2-3" class="t-7"></label>
<input type="radio" id="b7-3-1" class="player-1 left first-column bottom third-row second-diagonal t-7">
<label for="b7-3-1" class="t-7"></label>
<input type="radio" id="b7-3-2" class="player-1 middle second-column bottom third-row t-7">
<label for="b7-3-2" class="t-7"></label>
<input type="radio" id="b7-3-3" class="player-1 right third-column bottom third-row first-diagonal t-7">
<label for="b7-3-3" class="t-7"></label>
<input type="radio" id="b8-1-1" class="player-2 left first-column top first-row first-diagonal t-8">
<label for="b8-1-1" class="t-8"></label>
<input type="radio" id="b8-1-2" class="player-2 middle second-column top first-row t-8">
<label for="b8-1-2" class="t-8"></label>
<input type="radio" id="b8-1-3" class="player-2 right third-column top first-row second-diagonal t-8">
<label for="b8-1-3" class="t-8"></label>
<input type="radio" id="b8-2-1" class="player-2 left first-column center second-row t-8">
<label for="b8-2-1" class="t-8"></label>
<input type="radio" id="b8-2-2"
class="player-2 middle second-column center second-row first-diagonal second-diagonal t-8">
<label for="b8-2-2" class="t-8"></label>
<input type="radio" id="b8-2-3" class="player-2 right third-column center second-row t-8">
<label for="b8-2-3" class="t-8"></label>
<input type="radio" id="b8-3-1" class="player-2 left first-column bottom third-row second-diagonal t-8">
<label for="b8-3-1" class="t-8"></label>
<input type="radio" id="b8-3-2" class="player-2 middle second-column bottom third-row t-8">
<label for="b8-3-2" class="t-8"></label>
<input type="radio" id="b8-3-3" class="player-2 right third-column bottom third-row first-diagonal t-8">
<label for="b8-3-3" class="t-8"></label>
<input type="radio" id="b9-1-1" class="player-1 left first-column top first-row first-diagonal t-9">
<label for="b9-1-1" class="t-9"></label>
<input type="radio" id="b9-1-2" class="player-1 middle second-column top first-row t-9">
<label for="b9-1-2" class="t-9"></label>
<input type="radio" id="b9-1-3" class="player-1 right third-column top first-row second-diagonal t-9">
<label for="b9-1-3" class="t-9"></label>
<input type="radio" id="b9-2-1" class="player-1 left first-column center second-row t-9">
<label for="b9-2-1" class="t-9"></label>
<input type="radio" id="b9-2-2"
class="player-1 middle second-column center second-row first-diagonal second-diagonal t-9">
<label for="b9-2-2" class="t-9"></label>
<input type="radio" id="b9-2-3" class="player-1 right third-column center second-row t-9">
<label for="b9-2-3" class="t-9"></label>
<input type="radio" id="b9-3-1" class="player-1 left first-column bottom third-row second-diagonal t-9">
<label for="b9-3-1" class="t-9"></label>
<input type="radio" id="b9-3-2" class="player-1 middle second-column bottom third-row t-9">
<label for="b9-3-2" class="t-9"></label>
<input type="radio" id="b9-3-3" class="player-1 right third-column bottom third-row first-diagonal t-9">
<label for="b9-3-3" class="t-9"></label>
<div class="complete">
<h3></h3>
<a href="">Restart</a>
</div>
</div>
<h2>3 in a row</h2>
</body>
</html>
Below is the css code for this video.
style.css
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
width: 100%;
background: #efdecd;
font-family: monospace;
text-align: center;
}
h1, h2 {
position: absolute;
width: 100%;
color: #d7a17d;
font-size: 60px;
}
h1 {
top: 7.5%;
transform: translateY(-7.5%);
letter-spacing: 1px;
}
h2 {
top: 92.5%;
transform: translateY(-92.5%);
letter-spacing: 4px;
}
.tic-tac-toe-board {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
height: 450px;
width: 450px;
font-family: sans-serif;
overflow: hidden;
}
.tic-tac-toe-board input[type=radio] {
display: none;
}
.tic-tac-toe-board input[type=radio]:checked+label {
z-index: 10 !important;
cursor: default;
}
.tic-tac-toe-board input[type=radio].player-1+label::after {
content: "X";
}
.tic-tac-toe-board input[type=radio].player-2+label::after {
content: "O";
}
.tic-tac-toe-board input[type=radio].player-1:checked+label::after, .tic-tac-toe-board input[type=radio].player-2:checked+label::after {
opacity: 1;
}
.tic-tac-toe-board input[type=radio].player-1:checked+label {
background-color: #b19cd9;
}
.tic-tac-toe-board input[type=radio].player-2:checked+label {
background-color: #c54b8c;
}
.tic-tac-toe-board input[type=radio].t-1+label {
z-index: 1;
display: block;
}
.tic-tac-toe-board input[type=radio].t-2+label {
z-index: 2;
}
.tic-tac-toe-board input[type=radio].t-3+label {
z-index: 3;
}
.tic-tac-toe-board input[type=radio].t-4+label {
z-index: 4;
}
.tic-tac-toe-board input[type=radio].t-5+label {
z-index: 5;
}
.tic-tac-toe-board input[type=radio].t-6+label {
z-index: 6;
}
.tic-tac-toe-board input[type=radio].t-7+label {
z-index: 7;
}
.tic-tac-toe-board input[type=radio].t-8+label {
z-index: 8;
}
.tic-tac-toe-board input[type=radio].t-9+label {
z-index: 9;
}
.tic-tac-toe-board input[type=radio].t-1:checked~.t-2+label, .tic-tac-toe-board input[type=radio].t-2:checked~.t-3+label,
.tic-tac-toe-board input[type=radio].t-3:checked~.t-4+label, .tic-tac-toe-board input[type=radio].t-4:checked~.t-5+label,
.tic-tac-toe-board input[type=radio].t-5:checked~.t-6+label, .tic-tac-toe-board input[type=radio].t-6:checked~.t-7+label,
.tic-tac-toe-board input[type=radio].t-7:checked~.t-8+label, .tic-tac-toe-board input[type=radio].t-8:checked~.t-9+label,
.tic-tac-toe-board input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~.complete,
.tic-tac-toe-board .player-1.first-column:checked~.player-1.first-column:checked~.player-1.first-column:checked~.complete,
.tic-tac-toe-board .player-1.second-column:checked~.player-1.second-column:checked~.player-1.second-column:checked~.complete,
.tic-tac-toe-board .player-1.third-column:checked~.player-1.third-column:checked~.player-1.third-column:checked~.complete,
.tic-tac-toe-board .player-1.first-row:checked~.player-1.first-row:checked~.player-1.first-row:checked~.complete,
.tic-tac-toe-board .player-1.second-row:checked~.player-1.second-row:checked~.player-1.second-row:checked~.complete,
.tic-tac-toe-board .player-1.third-row:checked~.player-1.third-row:checked~.player-1.third-row:checked~.complete,
.tic-tac-toe-board .player-1.first-diagonal:checked~.player-1.first-diagonal:checked~.player-1.first-diagonal:checked~.complete,
.tic-tac-toe-board .player-1.second-diagonal:checked~.player-1.second-diagonal:checked~.player-1.second-diagonal:checked~.complete,
.tic-tac-toe-board .player-2.first-column:checked~.player-2.first-column:checked~.player-2.first-column:checked~.complete,
.tic-tac-toe-board .player-2.second-column:checked~.player-2.second-column:checked~.player-2.second-column:checked~.complete,
.tic-tac-toe-board .player-2.third-column:checked~.player-2.third-column:checked~.player-2.third-column:checked~.complete,
.tic-tac-toe-board .player-2.first-row:checked~.player-2.first-row:checked~.player-2.first-row:checked~.complete,
.tic-tac-toe-board .player-2.second-row:checked~.player-2.second-row:checked~.player-2.second-row:checked~.complete,
.tic-tac-toe-board .player-2.third-row:checked~.player-2.third-row:checked~.player-2.third-row:checked~.complete,
.tic-tac-toe-board .player-2.first-diagonal:checked~.player-2.first-diagonal:checked~.player-2.first-diagonal:checked~.complete,
.tic-tac-toe-board .player-2.second-diagonal:checked~.player-2.second-diagonal:checked~.player-2.second-diagonal:checked~.complete {
display: block;
}
.tic-tac-toe-board input[type=radio].left+label {
left: 0;
}
.tic-tac-toe-board input[type=radio].top+label {
top: 0;
}
.tic-tac-toe-board input[type=radio].middle+label {
left: 150px;
}
.tic-tac-toe-board input[type=radio].right+label {
left: 300px;
}
.tic-tac-toe-board input[type=radio].center+label {
top: 150px;
}
.tic-tac-toe-board input[type=radio].bottom+label {
top: 300px;
}
.tic-tac-toe-board input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~input[type=radio]:checked~.complete>h3::before {
content: "It's a draw!";
}
.tic-tac-toe-board .player-1.first-column:checked~.player-1.first-column:checked~.player-1.first-column:checked~.complete h3::before,
.tic-tac-toe-board .player-1.second-column:checked~.player-1.second-column:checked~.player-1.second-column:checked~.complete h3::before,
.tic-tac-toe-board .player-1.third-column:checked~.player-1.third-column:checked~.player-1.third-column:checked~.complete h3::before,
.tic-tac-toe-board .player-1.first-row:checked~.player-1.first-row:checked~.player-1.first-row:checked~.complete h3::before,
.tic-tac-toe-board .player-1.second-row:checked~.player-1.second-row:checked~.player-1.second-row:checked~.complete h3::before,
.tic-tac-toe-board .player-1.third-row:checked~.player-1.third-row:checked~.player-1.third-row:checked~.complete h3::before,
.tic-tac-toe-board .player-1.first-diagonal:checked~.player-1.first-diagonal:checked~.player-1.first-diagonal:checked~.complete h3::before,
.tic-tac-toe-board .player-1.second-diagonal:checked~.player-1.second-diagonal:checked~.player-1.second-diagonal:checked~.complete h3::before {
content: "Player 1 ( X ) wins!" !important;
}
.tic-tac-toe-board .player-2.first-column:checked~.player-2.first-column:checked~.player-2.first-column:checked~.complete h3::before,
.tic-tac-toe-board .player-2.second-column:checked~.player-2.second-column:checked~.player-2.second-column:checked~.complete h3::before,
.tic-tac-toe-board .player-2.third-column:checked~.player-2.third-column:checked~.player-2.third-column:checked~.complete h3::before,
.tic-tac-toe-board .player-2.first-row:checked~.player-2.first-row:checked~.player-2.first-row:checked~.complete h3::before,
.tic-tac-toe-board .player-2.second-row:checked~.player-2.second-row:checked~.player-2.second-row:checked~.complete h3::before,
.tic-tac-toe-board .player-2.third-row:checked~.player-2.third-row:checked~.player-2.third-row:checked~.complete h3::before,
.tic-tac-toe-board .player-2.first-diagonal:checked~.player-2.first-diagonal:checked~.player-2.first-diagonal:checked~.complete h3::before,
.tic-tac-toe-board .player-2.second-diagonal:checked~.player-2.second-diagonal:checked~.player-2.second-diagonal:checked~.complete h3::before {
content: "Player 2 ( O ) wins!" !important;
}
.tic-tac-toe-board label {
position: absolute;
display: none;
height: 140px;
width: 140px;
background-color: #f89880;
color: #efdecd;
border-radius: 8px;
margin: 5px;
cursor: pointer;
transition: background-color 0.25s ease;
}
.tic-tac-toe-board label:hover {
background-color: #404040;
}
.tic-tac-toe-board label::after {
position: absolute;
top: 50%;
left: 0;
width: 100%;
font-size: 70px;
text-align: center;
margin-top: -35px;
text-shadow: 4px 4px 8px #00000040;
opacity: 0;
}
.tic-tac-toe-board label:hover::after {
opacity: 0.5;
}
.tic-tac-toe-board .complete {
position: absolute;
top: 5px;
left: 5px;
bottom: 5px;
right: 5px;
display: none;
background: #efdecdbf;
color: #0f52ba;
padding-top: 110px;
text-align: center;
z-index: 11;
}
.tic-tac-toe-board .complete h3 {
color: #0f52ba;
font-size: 60px;
font-weight: 600;
margin: 35px auto;
}
.tic-tac-toe-board .complete a {
text-decoration: none;
background-color: #0f52ba;
color: #efdecd;
border-radius: 4px;
padding: 15px 30px;
transition: background-color 0.25s ease;
cursor: pointer;
}
.tic-tac-toe-board .complete a:hover {
background-color: #120a8f;
}
Thanks for visiting