Ask your own question, for FREE!
edX CS50x Intro to CS I 21 Online
OpenStudy (davidusa):

WEB DEV JS AND PHP

OpenStudy (davidusa):

Hi. I am starting to program dots and boxes. The rest of my website is written in php html and css. However, for this part I will need css. How do I write the js? Where do I put it?

OpenStudy (davidusa):

@rsmith6559

OpenStudy (osanseviero):

You have a file with css. It is the same with javascript. You just have to add it at the end of the file instead of the header

OpenStudy (woodrow73):

Here's a skeleton for you, where css can be placed inside the head, and javascript at the bottom of the body. `<!doctype html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>title</title> <style type="text/css"> #box { background-color: blue; width: 100px; height: 100px; } </style> </head> <body> <div id="box"></div> <script type="text/javascript"> document.getElementById("box").onclick = function() { alert("you clicked"); } </script> </body> </html>` You can even keep the files separate, and just reference to them like so; `<!doctype html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>title</title> <link rel="stylesheet" type="text/css" href="url.css" /> </head> <body> <div id="box"></div> <script type="text/javascript" src="url.js"></script> </body> </html>`

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!