171k views
3 votes
What is the difference between IDs and classes in CSS?

A) IDs are used for HTML elements, and classes are used for CSS rules.
B) IDs are unique and can be used only once per page, while classes can be used multiple times.
C) IDs can only be applied to block-level elements, while classes can be applied to inline elements.
D) IDs and classes have no difference; they are interchangeable.

User Rooby
by
8.3k points

1 Answer

4 votes

Final answer:

IDs are used for individual elements, while classes are used for grouping multiple elements.

Step-by-step explanation:

The difference between IDs and classes in CSS is that IDs are used to identify and style individual HTML elements, while classes are used to group and style multiple elements.

IDs are unique and can only be used once per page, while classes can be used multiple times.

While IDs can be applied to any HTML element, classes can be applied to both block-level and inline elements.

User Igorgue
by
8.0k points