What is the purpose of a class selector in CSS?
Answer: A class selector is used to apply styles to one or more elements with the same class name.
How do you define a class selector in CSS?
Answer: Use a period (.
) followed by the class name. Example: .example { color: red; }
#id
) is unique and applies to a single element..class
) can be reused for multiple elements.How do you apply a generic class selector to multiple elements?
Answer: Assign the same class name to multiple elements and define the styles in CSS using the class selector.
What is the purpose of the hover
pseudo-class in CSS?
Answer: It applies styles to an element when the user hovers over it with a mouse.
How do you style an element using an ID selector in CSS?
Answer: Use a hash (#
) followed by the ID name. Example: #example { color: blue; }
:hover
).::before
).button:hover
pseudo-class. Example: