Web Development quiz

HTML, CSS, JavaScript and how the web works.

80 questionsInstant feedbackFree

Set up your quiz

Difficulty
Number of questions

Tip: press 1–4 to answer and Enter for the next question.

All 80 questions with answers
  1. What does HTML stand for?

    • Hyper Trainer Marking Language
    • Hyper Text Markup Language (correct)
    • High Text Machine Language
    • Hyperlinks and Text Markup Language
  2. Which HTML tag is used to create a hyperlink?

    • <href>
    • <link>
    • <a> (correct)
    • <url>
  3. What does CSS stand for?

    • Cascading Style Sheets (correct)
    • Creative Style System
    • Computer Style Sheets
    • Colorful Style Syntax
  4. Which CSS property changes the text color?

    • font-color
    • fgcolor
    • text-style
    • color (correct)
  5. Which HTML tag defines the largest heading?

    • <h6>
    • <h1> (correct)
    • <head>
    • <heading>
  6. Which keyword declares a block-scoped variable that can be reassigned in JavaScript?

    • var
    • int
    • let (correct)
    • dim
  7. Which HTTP method is normally used to retrieve data from a server?

    • GET (correct)
    • POST
    • PUT
    • DELETE
  8. What does === do in JavaScript?

    • Compares value only
    • Compares value and type (correct)
    • Assigns a value
    • Compares type only
  9. Which Flexbox property aligns items along the main axis?

    • align-content
    • text-align
    • flex-wrap
    • justify-content (correct)
  10. Which of these is NOT a primitive data type in JavaScript?

    • string
    • boolean
    • float (correct)
    • undefined
  11. What does DOM stand for?

    • Data Object Mode
    • Document Order Model
    • Document Object Model (correct)
    • Display Object Management
  12. Which attribute provides alternative text for an image?

    • alt (correct)
    • title
    • src
    • name
  13. What is the default display value of a <div> element?

    • inline
    • block (correct)
    • flex
    • inline-block
  14. Which method converts a JSON string into a JavaScript object?

    • JSON.decode()
    • JSON.stringify()
    • JSON.toObject()
    • JSON.parse() (correct)
  15. Which HTTP status code means "Not Found"?

    • 200
    • 301
    • 404 (correct)
    • 500
  16. What is event bubbling in JavaScript?

    • Events travel from ancestors down to the target
    • Events travel from the target up through its ancestors (correct)
    • Events are cancelled automatically
    • Events fire only once
  17. What is a closure in JavaScript?

    • A function that closes the browser window
    • A way to end a loop
    • A private class field
    • A function that remembers variables from its outer scope (correct)
  18. What does CORS stand for?

    • Client Origin Request Security
    • Cross-Origin Request Session
    • Cross-Origin Resource Sharing (correct)
    • Central Origin Resource System
  19. What does an async function always return?

    • A Promise (correct)
    • undefined
    • A callback
    • A string
  20. How does sessionStorage differ from localStorage?

    • sessionStorage is shared across all tabs
    • localStorage is cleared when the tab closes
    • sessionStorage is cleared when the tab closes, localStorage persists (correct)
    • They are identical
  21. Which HTML tag creates a paragraph?

    • <para>
    • <p> (correct)
    • <pg>
    • <text>
  22. Which HTML tag inserts an image?

    • <pic>
    • <img> (correct)
    • <src>
    • <image>
  23. Which HTML tag creates an unordered (bulleted) list?

    • <list>
    • <ul> (correct)
    • <ol>
    • <li>
  24. Which HTML tag creates a numbered list?

    • <num>
    • <ul>
    • <ol> (correct)
    • <nl>
  25. Which tag is used for a single list item?

    • <item>
    • <ul>
    • <li> (correct)
    • <dl>
  26. Which HTML tag creates a table row?

    • <th>
    • <row>
    • <td>
    • <tr> (correct)
  27. Which HTML element holds the visible page content?

    • <head>
    • <html>
    • <body> (correct)
    • <meta>
  28. Where does the <title> tag go?

    • Inside <footer>
    • Inside <body>
    • Inside <head> (correct)
    • Before <html>
  29. Which tag creates a text input in a form?

    • <textfield>
    • <text>
    • <input type="string">
    • <input type="text"> (correct)
  30. Which CSS property changes the background colour?

    • color
    • background-color (correct)
    • bgcolor
    • fill
  31. Which CSS property changes the font size?

    • font-style
    • size
    • font-size (correct)
    • text-size
  32. Which CSS selector targets an element with id="main"?

    • .main
    • #main (correct)
    • *main
    • main
  33. Which CSS selector targets elements with class="card"?

    • card
    • #card
    • .card (correct)
    • @card
  34. Which CSS property adds space inside an element's border?

    • gap only
    • margin
    • padding (correct)
    • spacing
  35. Which CSS property adds space outside an element's border?

    • border-spacing
    • padding
    • margin (correct)
    • outline
  36. Where is JavaScript usually linked in an HTML page?

    • With a <script> tag (correct)
    • With a <js> tag
    • With a <link rel="js"> tag
    • With a <code> tag
  37. Which JavaScript method shows a message in the browser console?

    • alert.log()
    • document.print()
    • print()
    • console.log() (correct)
  38. Which keyword declares a constant in JavaScript?

    • final
    • let
    • const (correct)
    • var
  39. Which HTML attribute makes a link open in a new tab?

    • href="_blank"
    • target="_blank" (correct)
    • open="new"
    • new="tab"
  40. Which file extension is used for CSS files?

    • .css (correct)
    • .style
    • .cs
    • .sty
  41. What does the box-sizing: border-box rule do?

    • Makes the element a flex container
    • Includes padding and border in an element's width and height (correct)
    • Removes the border
    • Adds a box shadow
  42. Which CSS property creates a flex container?

    • align: flex
    • display: flex (correct)
    • position: flex
    • flex: 1
  43. Which property aligns flex items on the cross axis?

    • text-align
    • flex-direction
    • justify-content
    • align-items (correct)
  44. Which CSS property makes a grid with three equal columns?

    • grid-columns: 3
    • grid: 3fr
    • grid-template-columns: repeat(3, 1fr) (correct)
    • columns: 3 equal
  45. What does position: absolute position an element relative to?

    • Its nearest positioned ancestor (correct)
    • The body only
    • The browser window always
    • Its previous sibling
  46. What does position: sticky do?

    • Makes it draggable
    • Fixes the element permanently
    • Removes it from layout
    • Acts like relative until a scroll threshold, then sticks (correct)
  47. What is a media query used for?

    • Applying styles based on screen size or device features (correct)
    • Querying a database
    • Playing media files
    • Loading images lazily
  48. Which unit is relative to the root element's font size?

    • em
    • rem (correct)
    • vh
    • px
  49. What does 100vh mean in CSS?

    • 100 em units
    • 100 pixels
    • 100% of the parent
    • 100% of the viewport height (correct)
  50. What does document.querySelector(".btn") return?

    • All matching elements
    • The first element matching the selector (correct)
    • A CSS rule
    • The number of matches
  51. Which method attaches an event handler in JavaScript?

    • attachHandler()
    • addEventListener() (correct)
    • listen()
    • onEvent()
  52. What does Array.prototype.map() return?

    • The same array modified
    • A boolean
    • A single value
    • A new array with each element transformed (correct)
  53. What does Array.prototype.filter() return?

    • A new array with elements that pass a test (correct)
    • The first matching element
    • A boolean
    • The index of a match
  54. What does Array.prototype.reduce() do?

    • Removes elements
    • Combines all elements into a single value (correct)
    • Sorts elements
    • Reverses elements
  55. What is the difference between let and var?

    • let is function-scoped
    • let is block-scoped; var is function-scoped (correct)
    • They are identical
    • var cannot be reassigned
  56. What does typeof null return in JavaScript?

    • "number"
    • "null"
    • "undefined"
    • "object" (correct)
  57. What does fetch() return?

    • A Promise (correct)
    • An XMLHttpRequest
    • A string
    • The response body directly
  58. What does JSON.stringify() do?

    • Parses JSON text
    • Validates JSON
    • Converts a JavaScript value to a JSON string (correct)
    • Downloads JSON
  59. What is the purpose of semantic HTML tags like <article> and <nav>?

    • They add styling automatically
    • They describe the meaning of content for accessibility and SEO (correct)
    • They load faster
    • They run JavaScript
  60. What is the purpose of the <meta name="viewport"> tag?

    • Adds keywords for SEO
    • Sets the page title
    • Controls page scaling and width on mobile devices (correct)
    • Links a stylesheet
  61. What is the CSS specificity order from strongest to weakest?

    • Id, inline, class, element
    • Inline style, id, class, element (correct)
    • Class, id, element, inline
    • Element, class, id, inline
  62. What does the spread operator ... do with arrays?

    • Joins strings
    • Creates a range
    • Expands an array into individual elements (correct)
    • Deletes elements
  63. What is a template literal in JavaScript?

    • A string in backticks that can embed ${expressions} (correct)
    • A CSS template
    • A JSON schema
    • A reusable HTML file
  64. What does the HTTP status code 500 mean?

    • Internal server error (correct)
    • Unauthorized
    • Not found
    • OK
  65. What does the HTTP status code 201 mean?

    • Accepted for later
    • Created (correct)
    • No content
    • OK
  66. What is the event loop in JavaScript?

    • A browser plugin
    • A loop that listens for clicks
    • The mechanism that runs queued callbacks when the call stack is empty (correct)
    • A for loop over events
  67. Which runs first: a resolved Promise callback or a setTimeout(fn, 0) callback?

    • The Promise callback (microtask) (correct)
    • It is random
    • The setTimeout callback
    • They run at the same time
  68. What does await do inside an async function?

    • Retries the Promise
    • Blocks the whole browser
    • Pauses the function until the Promise settles (correct)
    • Creates a new thread
  69. What is the virtual DOM in React?

    • An in-memory representation used to compute minimal real DOM updates (correct)
    • A CSS framework
    • A second browser window
    • A server-side DOM
  70. What does React's useState hook return?

    • The current state value and a function to update it (correct)
    • Only the state value
    • A ref to a DOM node
    • A Promise
  71. When does a useEffect with an empty dependency array run?

    • Once after the first render (correct)
    • On every render
    • Never
    • Before the first render
  72. What is event delegation?

    • Passing events to the server
    • Cancelling events
    • Handling events on a parent element instead of each child (correct)
    • Creating custom events only
  73. What does event.preventDefault() do?

    • Stops the browser's default action for the event (correct)
    • Removes the event listener
    • Stops the event from bubbling
    • Reloads the page
  74. What is the difference between == and === in JavaScript?

    • == only compares strings
    • === converts types
    • They are identical
    • == converts types before comparing; === does not (correct)
  75. Which HTTP header lets a server allow cross-origin requests from another site?

    • Cache-Control
    • Authorization
    • Access-Control-Allow-Origin (correct)
    • Content-Type
  76. What is XSS (cross-site scripting)?

    • A CSS framework
    • Cross-server syncing
    • Injecting malicious scripts into pages viewed by other users (correct)
    • A slow script error
  77. What is the main benefit of server-side rendering for SEO?

    • It makes images smaller
    • Search engines receive complete HTML without running JavaScript (correct)
    • It hides the source code
    • It removes the need for CSS
  78. What does the defer attribute on a <script> tag do?

    • Never runs the script
    • Runs the script immediately, blocking parsing
    • Downloads the script in parallel and runs it after the HTML is parsed (correct)
    • Runs it only on mobile
  79. What is debouncing?

    • Running a function repeatedly
    • Removing bugs
    • Delaying a function until events stop firing for a set time (correct)
    • Caching API results
  80. What does the CSS property z-index control?

    • Stacking order of positioned elements (correct)
    • Horizontal position
    • Opacity
    • Zoom level