Web Dev Practice Exam

HTML ยท CSS ยท JavaScript ยท DOM

โฑ 60 minutes ๐Ÿ“‹ 60 points 4 sections
60:00
Score: 0/60
Fill in the blank / Identify the term 15 pts ยท 1 pt each
Question 1 of 60
What does HTML stand for?
Question 2 of 60
What does CSS stand for?
Question 3 of 60
What HTML tag is used to embed JavaScript code directly inside an HTML file?
Question 4 of 60
In CSS, the space between the content and the border of an element is called the ___.
Question 5 of 60
What JavaScript method is used to select an HTML element by its id attribute?
Question 6 of 60
What does DOM stand for?
Question 7 of 60
HTML attributes always appear in the ___ tag of an element.
Question 8 of 60
In JavaScript, what keyword is used to declare a variable?
Question 9 of 60
What CSS property changes the text color of an element?
Question 10 of 60
Which HTML tag creates an unordered (bulleted) list?
Question 11 of 60
In the CSS Box Model, the ___ is the outermost space โ€” the area outside the border.
Question 12 of 60
The DOM represents an HTML document as a ___ of objects.
Question 13 of 60
In JavaScript, what symbol is used for the modulus (remainder) operator?
Question 14 of 60
What HTML attribute do you use in the <a> tag to define the link destination?
Question 15 of 60
In JavaScript, the element.addEventListener("___", function) method attaches events to elements. What event would you use for a mouse click?
Choose the best answer 20 pts ยท 2 pts each
Question 16 of 60
Which of the following is the correct CSS selector for targeting an element with the id of "header"?
Question 17 of 60
Which HTML tag is used to define the largest heading?
Question 18 of 60
What will this JavaScript code output: document.getElementById("demo").innerHTML = 5 + 6;
Question 19 of 60
In the DOM tree, what is the root element of an HTML document?
Question 20 of 60
Which CSS method applies styles directly on an HTML element using the style attribute?
Question 21 of 60
Which of the following is NOT a popular scripting language?
Question 22 of 60
To link an external JavaScript file named app.js, which tag is correct?
Question 23 of 60
In JavaScript, what does ** represent?
Question 24 of 60
Which DOM method would you use to select all elements with the class name "box"?
Question 25 of 60
In a JS function, what does the return statement do?
True or False โ€” if False, correct the underlined word/phrase 15 pts ยท 1.5 pts each
Question 26 of 60
HTML elements label pieces of content and HTML attributes tell the browser how to display the content.
Question 27 of 60
CSS stands for Cascading Style Sheets and is used to style HTML documents.
Question 28 of 60
In JavaScript, the window.alert() method displays a confirm box in the browser.
Question 29 of 60
The innerHTML property is used to get or set the HTML content of an element.
Question 30 of 60
In the CSS Box Model, the border is the space outside the element, surrounding the margin.
Question 31 of 60
A scripting language is a programming language that automates the execution of tasks in a special run-time environment.
Question 32 of 60
In HTML, the <img> tag uses the src attribute to specify the image file path.
Question 33 of 60
The DOM allows scripts to update content, change element attributes, and respond to user interactions.
Question 34 of 60
In JavaScript, semicolons are used to end a block of code like a function or if-statement.
Question 35 of 60
The CSS class selector is written with a hash (#) symbol before the name.
Find & fix ALL bugs โ€” rewrite the corrected code in the editor 10 pts ยท 2 pts each
Each block below contains buggy code. Read carefully, find all the errors, then rewrite the entire corrected code in the editor below it. You won't be told how many errors there are.
Question 36 of 60 ยท 2 pts
This function is supposed to greet a user by their name and display it on the element with id "output". Find all errors and rewrite the corrected code.
 1function greetUser() {
 2  var name = document.getElementByID("username").value;
 3  var msg = "Hello, " + name;
 4  document.getElementById("output").innerhtml = msg;
 5}
โœ Rewrite the corrected code below:
Question 37 of 60 ยท 2 pts
This code is supposed to add a click event to a button so it changes the color of a paragraph to blue. Find all errors and rewrite the corrected code.
 1var btn = document.querySelector("#myBtn");
 2var para = document.querySelector("#myPara");
 3
 4btn.addEventListener("onclick", function() {
 5  para.style.colour = "blue";
 6});
โœ Rewrite the corrected code below:
Question 38 of 60 ยท 2 pts
This function checks if an input field is empty and shows an alert. It also attempts to remove a CSS class. Find all errors.
 1function validateForm() {
 2  var input = document.getElementById("email");
 3  if (input.value = "") {
 4    alert("Email is required");
 5    input.setAttribute("class");
 6  }
 7}
โœ Rewrite the corrected code below:
Question 39 of 60 ยท 2 pts
This function is supposed to loop through a list of items (a NodeList) and log each item's text content. Find all errors.
 1function listItems() {
 2  var items = document.querySelectorAll(".item");
 3  for (var i = 0; i < items.lenght; i++) {
 4    console.log(items[i].textContent);
 5  }
 6}
โœ Rewrite the corrected code below:
Question 40 of 60 ยท 2 pts
This code creates a new paragraph element, sets its text, and appends it to the body. Find all errors.
 1var newPara = document.createElement("p");
 2newPara.innerText = "This is new!";
 3newPara.setStyle("color", "green");
 4document.body.appendChild(newPara);
โœ Rewrite the corrected code below:
Quick True or False (no correction needed) 10 pts ยท 0.5 pts each ยท 20 items
Submit when you're done to see your final score
0/60
FINAL SCORE
0/15
Identification
0/20
Multiple Choice
0/15
Modified T/F
0/10
Error Tracing
0/10
Rapid Fire