I want to ask a rather simple question: how can I code a Tic Tac Toe table using HTML5 and CSS3? Here is the code I ran:
HTML
<!DOCTYPE html>
<html>
<head>
<title> Tic Tac Toe</title>
<link rel="stylesheet" type="text/css" href="Tic Tac Toe.css" media="screen"/>
<script type="text/javascript" src="Tic Tac Toe.js"></script>
<meta charset= "utf-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<div id="square1"></div>
<div id="square2"></div>
<div id="square3"></div>
<div id="square4"></div>
<div id="square5"></div>
<div id="square6"></div>
<div id="square7"></div>
<div id="square8"></div>
<div id="square9"></div>
</body>
</html>
CSS
#square1 {
background-color: yellow;
width: 50px;
height: 50px;
margin-left: 700px;
position: static;
}
#square2 {
background-color: grey;
width: 50px;
height: 50px;
margin-left: 700px;
position: static;
}
#square3 {
background-color: yellow;
width: 50px;
height: 50px;
margin-left: 700px;
position: static;
}
#square4 {
background-color: grey;
width: 50px;
height: 50px;
margin-bottom: -40px;
}
#square5 {
background-color: yellow;
width: 50px;
height: 50px;
}
#square6 {
background-color: grey;
width: 50px;
height: 50px;
}
#square7 {
background-color: yellow;
width: 50px;
height: 50px;
}
#square8 {
background-color: grey;
width: 50px;
height: 50px;
}
#square9 {
background-color: yellow;
width: 50px;
height: 50px;
}
Can someone please tell me what to do with those divs, so I can group them like a board? I tried drawing 9 squares, then grouping them together in the form of a board. But I cannot, when I am trying to move a div near another it just disappears. I really need a hand :)))
Also, I noticed that most people code this in JavaScript. Did I make my life a lot harder trying to code it in CSS3 and HTML? :D
Thanks a lot in advance!