Kelsey Chan and Kelsey Wong
Brought to you by Kelsey Chan and Kelsey Wong
HTML is a markup language that defines the structure of a web page.
<p>Some text here.</p>
<a href="https://www.google.com">Link to
Google</a>
<div>
<p>Some text here.</p>
<p>Some <b>bold</b> text below.</p>
</div>
HTML can be nested
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width">
<title>Add your title here!</title>
</head>
<body>
<p>Here is some <b>bold</b> text.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width">
<title>Add your title here!</title>
</head>
<body>
<p>Here is some <b>bold</b> text.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width">
<title>Add your title here!</title>
</head>
<body>
<p>Here is some <b>bold</b> text.</p>
</body>
</html>
h1 {
font-size: 32px;
color: blue;
}
h1 is the selector
font-size and color are properties
32px and blue are values
<p>Reviews of Harry Potter and the Sorcerer's Stone</p>
<p>Kelsey's review...</p>
<p>Anna's review...</p>
<p>Emily's review...</p>
<p>Reviews of Harry Potter and the Sorcerer's Stone</p>
<p>Kelsey's review...</p>
<p>Anna's review...</p>
<p>Emily's review...</p>
p { ... }
<p>Reviews of Harry Potter and the Sorcerer's Stone</p>
<p class="review">Kelsey's review...</p>
<p class="review">Anna's review...</p>
<p class="review">Emily's review...</p>
.review { ... }
<p>Reviews of Harry Potter and the Sorcerer's Stone</p>
<p class="review" id="my-review">...</p>
<p class="review">...</p>
<p class="review">...</p>
#my-review { ... }
Remember you can ask your peers and mentors for help 😎
The following HTML element tells the browser to apply the code in script.js to the HTML file:
<script src="script.js"></script>
In our script, we can use the document
variable to refer to our HTML document.
The document has many helpful functions, like:
document.getElementById("my-id");
document.getElementsByTagName("body");
document.querySelectorAll("div.some_class")
To make our web page interactive, we can add event listeners. This allows us to run certain code whenever an event (e.g. a button click) occurs.
let myButton = document.getElementById("my-button");
myButton.addEventListener("click", function() {
alert("Surprise!");
});
Remember you can ask your peers and mentors for help 😎