JavaScript, HTML, and CSS Practice Exam Questions, Exams of Technology

A practice exam for programming foundations with javascript, html, and css. It includes 31 multiple-choice questions covering various topics such as html elements, css properties, javascript keywords, dom manipulation, and more. Each question is followed by the correct answer and a brief explanation to reinforce understanding. This practice exam is designed to help students assess their knowledge and prepare for certification or further study in web development.

Typology: Exams

2025/2026

Available from 12/19/2025

shilpi-jain-1
shilpi-jain-1 🇮🇳

4.2

(5)

29K documents

1 / 110

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Programming Foundations with JavaScript HTML and
CSS Certificate Practice Exam
**Question 1. Which HTML element is used to define the most important heading
on a page?**
A) \<h3\>
B) \<header\>
C) \<h1\>
D) \<title\>
Answer: C
Explanation: \<h1\> denotes the primary heading and carries the highest semantic
weight for SEO and accessibility.
**Question 2. What does the <!DOCTYPE html> declaration do?**
A) Links an external stylesheet
B) Sets the page’s character encoding
C) Informs the browser to render the document in standards mode
D) Declares a JavaScript module
Answer: C
Explanation: The doctype tells browsers to use the HTML5 parsing algorithm,
avoiding quirks mode.
**Question 3. Which attribute makes an image inaccessible to screen readers?**
A) src
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download JavaScript, HTML, and CSS Practice Exam Questions and more Exams Technology in PDF only on Docsity!

CSS Certificate Practice Exam

Question 1. Which HTML element is used to define the most important heading on a page? A)
B)
C)
D)
Answer: C Explanation: \ denotes the primary heading and carries the highest semantic weight for SEO and accessibility. Question 2. What does the declaration do? A) Links an external stylesheet B) Sets the page’s character encoding C) Informs the browser to render the document in standards mode D) Declares a JavaScript module Answer: C Explanation: The doctype tells browsers to use the HTML5 parsing algorithm, avoiding quirks mode. Question 3. Which attribute makes an image inaccessible to screen readers? A) src

CSS Certificate Practice Exam

B) alt="" C) title D) width Answer: B Explanation: An empty alt attribute signals that the image is decorative and should be ignored by assistive technology. Question 4. In CSS, which selector has the highest specificity? A) .menu-item B) #mainNav C) article p D) * Answer: B Explanation: ID selectors (#) outrank class selectors (.) and element selectors in the specificity hierarchy. Question 5. Which CSS property is used to change the spacing between characters? A) letter-spacing B) word-spacing C) line-height

CSS Certificate Practice Exam

Question 8. How do you link an external CSS file named styles.css? A)
B) \

CSS Certificate Practice Exam

B) How width and height are calculated, including padding and border C) The element’s display type D) The element’s margin collapsing behavior Answer: B Explanation: border-box makes the total width/height include content, padding, and border. Question 11. Which JavaScript keyword is used to declare a block‑scoped variable that cannot be reassigned? A) var B) let C) const D) static Answer: C Explanation: const creates a read‑only binding; the variable identifier cannot be reassigned. Question 12. Which of the following is a primitive data type in JavaScript? A) Object B) Array C) Symbol

CSS Certificate Practice Exam

Explanation: A do…while loop checks its condition after executing the block, guaranteeing one execution. Question 15. What is the result of the expression 0 == false in JavaScript? A) true B) false C) TypeError D) undefined Answer: A Explanation: The loose equality operator (==) performs type coercion, converting false to 0, making the comparison true. Question 16. Which method adds an element to the end of an array? A) push() B) pop() C) shift() D) unshift() Answer: A Explanation: push() appends a new element and returns the new length of the array.

CSS Certificate Practice Exam

Question 17. In the DOM, which method retrieves an element with the id “header”? A) document.getElementsByClassName("header") B) document.querySelector("#header") C) document.getElementsByTagName("header") D) document.getElementById("header") Answer: D Explanation: getElementById directly returns the element whose id matches the supplied string. Question 18. Which event fires when a user changes the selected option of a \ element? A) click B) change C) input D) submit Answer: B Explanation: The change event triggers after the user commits a new selection. Question 19. How can you prevent a form from submitting when a button is clicked? A) return false; inside the onclick handler

CSS Certificate Practice Exam

D) Set the viewport for mobile devices Answer: B Explanation: charset declares the Unicode encoding, ensuring correct rendering of characters. Question 22. Which HTML element is appropriate for embedding a self‑contained piece of interactive content? A)
B)
C)
D)
Answer: D Explanation: \ provides a drawing surface for script‑generated graphics and interactivity. Question 23. In CSS Grid, what does the property grid-template-columns: 1fr 2fr; define? A) Two columns where the second is twice the width of the first B) Two rows with equal height C) A single column that occupies three fractions of space D) The gap between grid items Answer: A

CSS Certificate Practice Exam

Explanation: fr units allocate fractions of the free space; 2fr is double the width of 1fr. Question 24. Which JavaScript method is used to parse a JSON string into an object? A) JSON.stringify() B) JSON.parse() C) JSON.decode() D) JSON.objectify() Answer: B Explanation: JSON.parse converts a JSON‑formatted string into a JavaScript value or object. Question 25. What does the CSS pseudo‑class :first-child select? A) The first element of its type inside its parent B) The first child element of any type inside its parent C) The first element in the document tree D) Any element that appears first in the HTML source Answer: B Explanation: :first-child matches an element that is the first child node of its parent, regardless of type.

CSS Certificate Practice Exam

B) line-height C) text-indent D) word-spacing Answer: B Explanation: line-height sets the vertical distance between baselines of consecutive lines. Question 29. What is the output of console.log(typeof null) in JavaScript? A) "null" B) "object" C) "undefined" D) "boolean" Answer: B Explanation: Due to a historic bug, typeof null returns "object". Question 30. Which method removes the last element from an array and returns it? A) shift() B) pop() C) splice() D) slice()

CSS Certificate Practice Exam

Answer: B Explanation: pop() mutates the array by removing its final element and returns that element. Question 31. Which HTML element is used to define a navigation block? A)
B)
C)
D)
Answer: A Explanation: \ semantically groups navigation links. Question 32. Which CSS selector matches any element that has a class attribute containing the word “error”? A) .error B) [class="error"] C) [class*="error"] D) :error Answer: C Explanation: The attribute selector *="error" matches substrings within the class attribute.

CSS Certificate Practice Exam

A) Hides the element but retains its space B) Removes the element from the document flow entirely C) Makes the element invisible but still focusable D) Sets the element’s opacity to 0 Answer: B Explanation: display:none removes the element from layout calculations, freeing its space. Question 36. Which JavaScript function can be used to delay execution of a callback by 2 seconds? A) setInterval(callback, 2000) B) setTimeout(callback, 2000) C) delay(callback, 2000) D) wait(callback, 2000) Answer: B Explanation: setTimeout invokes the callback once after the specified delay in milliseconds. Question 37. In CSS, what is the purpose of the “z-index” property? A) Controls the stacking order of positioned elements B) Sets the zoom level of an element

CSS Certificate Practice Exam

C) Defines the number of columns in a grid D) Adjusts the element’s opacity Answer: A Explanation: z-index only works on positioned elements (relative, absolute, fixed, sticky) and determines which appears on top. Question 38. Which HTML attribute is used to provide alternative text for an image? A) title B) src C) alt D) href Answer: C Explanation: The alt attribute supplies descriptive text for accessibility and when the image fails to load. Question 39. What is the result of the expression [] == false in JavaScript? A) true B) false C) TypeError D) undefined

CSS Certificate Practice Exam

Explanation: parseInt parses from the start of the string until it encounters an invalid character. Question 42. In HTML, which element is used to define a block of pre‑formatted text? A)
B)
C)
D)
Answer: B Explanation: \ preserves whitespace and line breaks exactly as written. Question 43. Which CSS selector selects every third list item in an unordered list? A) li:nth-child(3) B) li:nth-of-type(3) C) li:nth-child(3n) D) li:nth-child(3n+1) Answer: C Explanation: nth-child(3n) matches every element whose index is a multiple of 3 (3,6,9,…).

CSS Certificate Practice Exam

Question 44. What does the JavaScript expression (true && false) || (!false) evaluate to? A) true B) false C) undefined D) NaN Answer: A Explanation: true && false → false; !false → true; false || true → true. Question 45. Which HTML element is used to embed a video file? A)
B)
C)
D)
Answer: C Explanation: \ provides native video playback with controls, source, and fallback options. Question 46. In CSS, what does the property “flex-wrap: wrap;” achieve in a flex container? A) Forces all items onto a single line