Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

Which selector is used to select all <div> elements inside a <section>?

View

What is the difference between getElementsByClassName and querySelectorAll?

View

Which of the following will select the last child element of a parent?

View

What does the :first-child pseudo-class do in a selector?

View

How would you select every <li> element that is a direct child of a <ul>?

View

Which of the following is a valid CSS selector used in querySelector?

View

What will document.querySelectorAll('.className') return?

View

How can you select all <a> elements that are inside a <nav>?

View

Which method would you use to find elements by their tag name?

View

How can you select all elements of a specific type in a document, for example, all <h1> tags?

View

Which selector is used to select all <div> elements inside a <section>?

section div
section>div
div.section
div+section

What is the difference between getElementsByClassName and querySelectorAll?

One returns a live HTMLCollection, the other a static NodeList
Both return a live HTMLCollection
Both return a static NodeList
There is no difference

Which of the following will select the last child element of a parent?

parentElement.lastChild
parentElement.lastElementChild
parentElement.children[parentElement.children.length - 1]
Both b and c

What does the :first-child pseudo-class do in a selector?

Selects the first element of the specified type
Selects the first child of a parent element
Selects the last child of a parent element
Selects all children of a parent

How would you select every <li> element that is a direct child of a <ul>?

ul > li
ul li
ul:child(li)
ul.child(li)

Which of the following is a valid CSS selector used in querySelector?

'#myId .myClass'
'div > p:first-child'
'.myClass:first-of-type'
All of the above

What will document.querySelectorAll('.className') return?

The first element with the class className
An array of all elements with the class className
A NodeList of all elements with the class className
None of the above

How can you select all <a> elements that are inside a <nav>?

nav + a
nav a
nav.a
nav > a

Which method would you use to find elements by their tag name?

document.getElementsByTagName()
document.querySelector()
document.getElementsByClassName()
document.querySelectorAll()

How can you select all elements of a specific type in a document, for example, all <h1> tags?

document.querySelector('h1')
document.getElementsByTagName('h1')
document.getElementsByClassName('h1')
document.querySelectorAll('h1')