I am working on a text based game. I am only having some trouble with formatting. I want the text to be white and the background to be black throughout the entire code. I set both of those in style. When I run the script, the styling works and the background is the color that I want, but as soon as I answer a prompt, the background reverts to default white and ignores the styling all together.
<head>
<style>
#game {
width:1100
}
body {background-color:black}
p {color:white}
</style>
</head>
<body>
<div id="game">
<script type="text/javascript">
window.onload = function() {
var seed = prompt("What kind of potato do you want to be? A RUSSET POTATO, RED POTATO, or SWEET POTATO?")
switch(seed) {
case 'RUSSET POTATO' :
document.write("<p>Hot diggity! You became a Russet Potato!</p>");
break;
case 'RED POTATO' :
document.write("<p>Greetings comrade! Welcome to the potatoes of Soviet Socialist Republics!</p>");
break;
case 'SWEET POTATO' :
document.write("<p>Hey there sweet thing! You're such a Sweet Potato!</p>");
break;
default:
document.write("<p>Make sure you are spelling your answers correctly and typing them in all caps!</p>");
}
var soil = prompt("What type of soil will you be planted in? PODZOL, STUTTGART, RED, AKADAMA, or CLAY?");
switch(soil) {
case 'PODZOL' :
document.write("There are many minerals, but the acid is ruining the shell of your seed! You die an agonizing and slow death.");
//link to lose page
break;
case 'STUTTGART' :
document.write("Your seed is nice and cozy in its new home. Happy growing!");
break;
case 'RED' :
document.write("Good choice comrade, but communism isn't always the best choice. Getting water will be a bit difficult.");
break;
case 'AKADAMA' :
document.write("It will be a bit difficult to grown roots, but you are a tough little seed! Hope you can grow well!");
break;
case 'CLAY' :
document.write("A hard rain comes in and your potato drowns.");
//link to lose page
break;
default:
document.write("Make sure you are spelling your answers correctly and typing them in all caps!");
}
}
</script>
</div>
</body>
</html>
I can not seem to figure out how to keep my html style the same when running javascript code. If anyone could help me out here, it would be much appreciated!