8- 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.
<!--index.html-->
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Change backgroud color on User Input</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='style.css'>
</head>
<body>
<h1 id="heading">Input backgroud Color</h1>
<input type="text" id="color" placeholder="Enter Backgroud Color : ">
<input type="submit" value="Submit" onclick="backchange()">
<br>
<div class="divselect">
<h2>Simple Web Page</h2>
<h3>For Changing Backgroud Color in</h3>
<h4>Red, Blue or Yellow</h4>
<h5>External link are not provided</h5>
<p>Using External <b>CSS</b> and a bit of <i>JavaScript</i> for validation and backgroundColor change</p>
<a href="#color">Refresh</a><br>
<img src="#" >
<br>
<table>
<tr>
<th>Table Heading 1</th>
<th>Table Heading 2</th>
<th>Table Heading 3</th>
</tr>
<tr>
<td>temp 1</td>
<td>temp 2</td>
<td>temp 3</td>
</tr>
<tr>
<td>temp 4</td>
<td>temp 5</td>
<td>temp 5</td>
</tr>
<tr>
<td>temp 7</td>
<td>temp 8</td>
<td>temp 9</td>
</tr>
</table>
</div>
<script>
function backchange() {
var col = document.getElementById("color").value;
colorss = col.toLowerCase();
if (colorss === "red" || colorss == "blue" || colorss == "yellow") {
document.body.style.backgroundColor = colorss;
}
else {
var col = prompt("Please Enter a valid Backgroud Color : ");
colorss = col.toLowerCase();
if (colorss === "red" || colorss == "blue" || colorss == "yellow") {
document.body.style.backgroundColor = colorss;
} else {
backchange();
}
}
}
</script>
</body>
</html>
/*style.css*/
body {
text-align: center;
margin: 10%;
}
a {
text-decoration: none;
}
input[type="submit"] {
border: 2px solid rgb(0, 0, 0);
padding: 5px;
font-size: 18px;
cursor: pointer;
margin: 12px 0;
padding: 10px;
}
input[type="submit"]:hover, input[type="text"]:hover {
border-color: #646464;
}
input[type="text"] {
font-size: 18px;
padding: 10px;
border: 2px solid rgb(0, 0, 0);
}
table {
width: 110%;
}
table, th, td {
border: 2px solid teal;
}
.divselect {
background: #d4d4d471;
padding: 13%;
border-radius: 50px;
}
#heading {
color: rgba(0, 0, 0, 0.678);
}
5 index.html Change Background by user input index.html html, body div.divselect\ table <td>temp 1</td> <td>temp 2</td> ----<td>temp 3</td> </tr> <tr> ----<td>temp 4</td> <td>temp 5</td> -----<td>temp 5</td> </tr> <tr> -- ---<td>temp 7</td> -<td>temp 8</td> -- ---<td>temp 9</td> - - - - </tr> ----/table] -- </div> - <script> function backchange() { ...var col = document.getElementById("color").value; colorss = col.toLowerCase(); if (colorss === "red" || colorss == "blue". Il colorss == -"yellow") { document.body.style.backgroundColor = colorss; } else { var col = prompt("Please Enter a valid Backgroud Color: "); colorss = col.toLowerCase(); if (colorss === - "red" || colorss == "blue". Il colorss == "yellow") { document.body.style.backgroundColor = colorss; -----} else { --- backchange(); ----</script> </body> </html> AO HTML Port : 5500 41
3 style.css Change Background by user input style.css\ s input[type="submit"], body { ---- text-align: center; ----margin: 10%; a { --- text-decoration: none; input[type="submit"] { border: 2px solid Orgb(0, 0, 0); padding: 5px; font-size: 18px; cursor: pointer; margin: 12px ; padding: 10px; input[type="submit"]:hover, input[type="text"]:hover { ---border-color: #646464; input[type="text"] { font-size: 18px; padding: 10px; ---- border: 2px solid Orgb(0, 0, 0); table { ----width: 110%; table, th, td { ---- border: 2px solid teal; .divselect { 0AO CSS Port : 5500 41
3 style.css Change Background by user input style.css 3 input[type="submit"] input[type="text"] { font-size: 18px; padding: 10px; ---- border: 2px solid Orgb(0, 0, 0); table { ----width: 110%; table, th, td { ---- border: 2px solid teal; .divselect { ---- background: #d4d4d471; ---padding: 13%; ---border-radius: 50px; #heading { ----color: rgba(0, 0, 0, 0.678); 0AO CSS Port : 5500 41
Get Answers For Free
Most questions answered within 1 hours.