Docsity

(Intermediate HTML & CSS) Advanced Selectors Knowledge Assessment Guide 2024, Exams of Computer Science

Partial preview of the text

Download (Intermediate HTML & CSS) Advanced Selectors Knowledge Assessment Guide 2024 and more Exams Computer Science in PDF only on Docsity!

INTERMEDIATE HTML & CSS

Advanced Selectors

KNOWLEDGE ASSESSMENT GUIDE

  1. Multiple Choice: Which of the following selectors is used to target an element based on its position in the document hierarchy? A. :first-child B. :nth-of-type C. :not() D. :empty

Correct Answer: B. :nth-of-type

Rationale: The :nth-of-type selector allows you to select elements based on their index in relation to their parent element.

  1. Fill in the Blank: The ________ selector is used to target elements that do not match a specified selector.

Correct Answer: :not()

Rationale: The :not() selector is used to select elements that do not match a specific selector.

  1. True/False: The :only-child selector targets elements that are the only child of their parent element.

Correct Answer: True

Correct Answer: True

Rationale: The :empty selector is used to select elements that do not contain any child elements.

  1. Multiple Choice: Which of the following selectors is used to target elements that have a specific attribute with a value that starts with a specified string? A. [attribute^="value"] B. [attribute$="value"] C. [attribute ="value"] D. [attribute|="value"]

Correct Answer: A. [attribute^="value"]

Rationale: The [attribute^="value"] selector targets elements with a specific attribute and value that starts with a specified string.

  1. Fill in the Blank: The ________ selector is used to target elements that have a specific attribute with a value that ends with a specified string.

Correct Answer: [attribute$="value"]

Rationale: The [attribute$="value"] selector targets elements with a specific attribute and a value that ends with a specified string.

  1. True/False: The :nth-of-type selector targets elements based on their position in relation to all elements of the same type within their parent element.

Correct Answer: True

Rationale: The :nth-of-type selector selects elements based on their position among all elements of the same type within their parent element.

  1. Multiple Choice: Which of the following is used to target odd elements within a parent element? A. :odd B. :even C. :nth-child(odd) D. :nth-child(even)

Correct Answer: C. :nth-child(odd)

Rationale: The :nth-child(odd) selector is used to target odd elements within a parent element. relevance to their level of study. Multiple Choice: Which of the following CSS selectors is used to select elements with a specific attribute value? A) Universal Selector B) Attribute Selector

B) Nth Child Selector C) Last Child Selector D) Root Selector

Correct Answer: B) Nth Child Selector

Rationale: The Nth Child Selector allows targeting elements based on their position within a set of siblings. Fill-in-the-Blank: The CSS selector that selects elements that are the first child of their parent is called the __.

Correct Answer: First Child Selector

Rationale: The First Child Selector is used to style elements that are the first child within their parent element. True/False: True or False: The :empty pseudo-class in CSS selects elements that do not contain any child elements or text.

Correct Answer: True

Rationale: The :empty pseudo-class targets elements that have no child elements or text content. Multiple Choice: Which CSS selector is used to select elements based on their language attribute?

A) Lang Selector B) Attribute Selector C) Type Selector D) ID Selector

Correct Answer: A) Lang Selector

Rationale: The Lang Selector is specifically used to target elements based on their language attribute. Fill-in-the-Blank: The CSS selector that selects elements that are the last child of their parent is called the __.

Correct Answer: Last Child Selector

Rationale: The Last Child Selector is employed to style elements that are the last child within their parent element. True/False: True or False: The :checked pseudo-class in CSS selects input elements that are checked.

Correct Answer: True

Rationale: The :checked pseudo-class is utilized to style input elements that are in a checked state. Multiple Choice:

Multiple Choice: Which CSS selector is used to select elements based on their scrollbar width? A) Scrollbar-Width Selector B) Overflow Selector C) Scrollbar Selector D) Webkit-Scrollbar Selector

Correct Answer: B) Overflow Selector

Rationale: The Overflow Selector targets elements based on their scrollbar properties. Fill-in-the-Blank: The CSS selector that selects elements based on their placeholder text is called the __.

Correct Answer: Placeholder Selector

Rationale: The Placeholder Selector allows styling of elements based on their placeholder text content. True/False: True or False: The :required pseudo-class in CSS selects input elements that are required to be filled out.

Correct Answer: True

Rationale: The :required pseudo-class is used to style input elements that require user input.

Multiple Choice: Which CSS selector is used to select elements based on their spelling errors? A) Spellcheck Selector B) Error Selector C) Validity Selector D) Bad-Input Selector

Correct Answer: C) Validity Selector

Rationale: The Validity Selector targets elements based on their validation status. Fill-in-the-Blank: The CSS selector that selects elements based on their placeholder text is called the __.

Correct Answer: Placeholder Selector

Rationale: The Placeholder Selector allows styling of elements based on their placeholder text content. True/False: True or False: The :read-only pseudo-class in CSS selects input elements that cannot be edited by the user.

Correct Answer: True

  • A) Class Selector
  • B) ID Selector
  • C) Attribute Selector
  • D) Universal Selector
  • Answer: C) Attribute Selector
  • Rationale: Attribute selectors are used to select elements with a specific attribute.
  1. What does the :nth-child(3n+1) selector do?
  • A) Selects every third element
  • B) Selects the first element in every group of three
  • C) Selects the second element in every group of three
  • D) Selects the third element in every group of three
  • Answer: B) Selects the first element in every group of three
  • Rationale: The :nth-child(3n+1) selector selects the first element in every group of three.
  1. Which pseudo-class selector is used to style an element when it is being activated by the user?
  • A) :hover
  • B) :focus
  • C) :active
  • D) :visited
  • Answer: C) :active
  • Rationale: The :active pseudo-class selector is used to style an element when it is being activated by the user.
  1. What does the :not(.class) selector do?
  • A) Selects all elements with the specified class
  • B) Selects all elements without the specified class
  • C) Selects the first element with the specified class
  • D) Selects the last element with the specified class
  • Answer: B) Selects all elements without the specified class
  • Rationale: The :not(.class) selector selects all elements that do not have the specified class.
  1. Which of the following selectors has the highest specificity?
  • A) Element Selector
  • B) Class Selector
  • C) ID Selector
  • D) Universal Selector
  • Answer: C) ID Selector
  • Rationale: The ID selector has the highest specificity among the given options.

Fill-in-the-Blank Questions

  1. The :last-of-type selector selects the __________ element of its type within its parent.
    • Answer: last
    • Rationale: The :last-of-type selector selects the last element of its type within its parent.

True/False Questions

  1. The :hover pseudo-class selector is used to style an element when the user hovers over it.
    • Answer: True
    • Rationale: The :hover pseudo-class selector is indeed used to style an element when the user hovers over it.
  2. The :nth-of-type(n) selector selects the nth element of a specific type within its parent.
    • Answer: True
    • Rationale: The :nth-of-type(n) selector selects the nth element of a specific type within its parent.
  3. The :root pseudo-class selector is used to select the root element of the document.
    • Answer: True
    • Rationale: The :root pseudo-class selector is used to select the root element of the document.
  1. The :empty pseudo-class selector selects elements that have no children, including text nodes.
    • Answer: True
    • Rationale: The :empty pseudo-class selector selects elements that have no children, including text nodes.
  2. The :lang pseudo-class selector is used to select elements based on their language attribute.
    • Answer: True
    • Rationale: The :lang pseudo-class selector is used to select elements based on their language attribute.
  3. The :nth-child(odd) selector selects all odd-numbered children of their parent.
    • Answer: True
    • Rationale: The :nth-child(odd) selector selects all odd-numbered children of their parent.
  4. The :nth-last-of-type(n) selector selects the nth element of a specific type from the end within its parent.
    • Answer: True
    • Rationale: The :nth-last-of-type(n) selector selects the nth element of a specific type from the end within its parent.