public_html it238 index.html styles.css myimage.jpg proj1a index.html proj1b index.html
Entity Symbol < < > > & & " " ' ' nonbreaking space β β (Greek letter beta) → → (right arrow) “ “ (left double quotes)You can look up other entities as needed. Here is a reference that contains the complete list of HTML entities:
foldera / | \ folderb s.css page1.html / page2.html
https://studentweb.cdm.depaul.edu/ssmith/index.htmHowever, you obtain this message:
<a href="/target.html">Go to Target Page</a>Answer: a relative URL should not start with a slash (/); it should just be href="target.html".
td { padding: 5px 10px 15px 20px; } Answer: 5 pixels padding on top; 10 pixels padding on the right; 15 pixels padding on the bottom; 20 pixels padding on the left. (The amount of padding specified starts at the top and goes around clockwise.) td { padding: 5px 10px 15px; } Answer: 5 pixels padding on top; 10 pixels padding on the left and right; 15 pixels padding on the bottom. td { padding: 5px 10px; } Answer: 5 pixels padding on top; 10 pixels padding on the left and right; 15 pixels padding on the bottom. td { padding: 5px; } Answer: 5 pixels padding on all sides.
<!DOCTYPE html> <html> <body> <script> document.writeln("Hello, World."); </script> </body>
document.writeln("Hello, World.");with
console.log("Hello, World.");Refresh the browser. Writing to the browser console is useful for debugging.
alert("Hello, World.");instead of
console.log("Hello, World.");
// BasicFunction Example // Function definition: function inToCm(inches) { cm = inches * 2.54; return cm; } // Function test: var inches = prompt("Enter length in inches", "0"); var cm = inToCm(inches); document.writeln("Length in cm: " + cm); // If input is 2, the output is 5.08
document.writeln("abc"); document.writeln("def");Why are the outputs on the same line? I thought that writeln puts a newline character (\n) at the end of its output. Place these statements in this test script before viewing the HTML page:
<html> <body> <script> // Copy JavaScript code to test here. </script> </body> </html>
<!DOCTYPE html> <!-- Birthday Riddle Example --> <html> <head> <title>Birthday Riddle</title> <style> body { background-color: #FFE0E0; color: navy; font-family: verdana, sans-serif; } </style> <script> function showAnswer( ) { var para = document.getElementById("p2"); para.innerHTML = "Answer: December 31; today is January 1."; } </script> </head> <body> <h1>Birthday Riddle</h1> <p id="p1">Riddle: The day before yesterday I was 21, and next year I will be 24. When is my birthday?</p> <p id="p2"></p> <input type="button" value="Show Answer" onclick="showAnswer( )"> <body> </html> Answer: ---- index.html ---------------------- <!DOCTYPE html> <!-- Birthday Riddle Example --> <html> <head> <title>Birthday Riddle</title> <link rel="stylesheet" href="styles.css"> <script src="script.js"></script> </head> <body> <h1>Birthday Riddle</h1> <p id="p1">Riddle: The day before yesterday I was 21, and next year I will be 24. When is my birthday?</p> <p id="p2"></p> <input type="button" id="btn1" value="Show Answer"> <body> </html> ---- styles.css ---------------------- /* BirthdayRiddle Example */ body { background-color: #FFE0E0; color: navy; font-family: verdana, sans-serif; } ---- script.js ----------------------- // BirthdayRiddle Example function showAnswer( ) { var para = document.getElementById("p2"); para.innerHTML = "Answer: December 31; today is January 1."; } function init( ) { var button = document.getElementById("btn1"); button.onclick = showAnswer; // or // button.addEventListener("click", showAnswer); } window.onload = init; // or // window.addEventListener("load", init); --------------------------------------An explanation of the riddle:
Date | My Age | Description |
---|---|---|
Dec 30, 2024 | 21 | Day Before Yesterday |
Dec 31, 2024 | 22 | My Birthday Last Year |
Jan 1, 2025 | 22 | Today |
Dec 31, 2025 | 23 | My Birthday This Year |
Dec 31, 2026 | 24 | My Birthday Next Year |