In: Computer Science
Develop a personal web page for yourself using HTML, CSS, and Javascript Use the following HTML tags to design your webpage: <h1>...</h1>,<h3>...</h3>, <h6>...</h6>, <p>...</p>, <b>...</b>, <i>...</i>, <a>...</a>, <img...>, <table>... </table>, <div>...</div>, <form>...</form>, <input type="text">, and <input type= "submit">
Use an external css to change the default style of your webpage. You must use at least one element selector, one id selector, and one class selector Using text input and submit button, allow the user to change the background color of your web page to red, blue, or yellow. When the user clicks the submit button to change the background color, you must first validate the user input to make sure the entered color is valid (red, blue, and yellow are valid colors). Then, you should change the background color of your web page. If the user didn’t enter a valid color, you should prompt the user to enter a valid color.
HTML code:
<!DOCTYPE html>
<html>
<head>
<title>Webpage</title>
<link rel="stylesheet" href="style.css">
<!for importing external css file>
</head>
<body>
<form>
<h2 class="hh">This page is
Home page</h2>
<p id="id1">Enter Your
color</p><input type="text" id="text1" placeholder="Enter
color"> <!text box declaration>
<input type="button"
value="submit" onclick="myFunction()"> <!calling function for
evaluation>
</form>
<script
type="text/javascript">
function myFunction() {
var
v=document.getElementById("text1").value;
if(v=='red'||v=='blue'||v=='yellow'){
if(v=='red'){
document.body.style.backgroundColor = "red";
}
if(v=='blue'){
document.body.style.backgroundColor = "blue";
}
if(v=='yellow'){
document.body.style.backgroundColor = "yellow";
}
}
else{
alert("Enter valid color");
}
}
</script>
</body>
</html>
css code:
body{
background-color: grey;
}
#id1{
color: lightblue;
font-size: 120%;
}
.hh{
color: black;
font-size: 120%;
color:black;
padding: 10px;
}
HTML code screenshot:
css code screenshot:
Note: Your css file name should be style.css