12. What are the differences between classes and IDs in CSS?

  • Class: Used for styling groups of elements. Can be used multiple times in a document. Identified by "." (dot).
  • ID: Used for styling a unique element. Can be used only once in a document. Identified by "#" (hash).
/* Examples */ .myClass { color: red; /* Class - can be used multiple times */ } #myId { color: blue; /* ID - should be unique */ }
devFlipCards 2024

Do you accept cookies?

Cookies are small amounts of data saved locally on you device, which helps our website - it saves your settings like theme or language. It helps in adjusting ads and in traffic analysis. By using this site, you consent cookies usage.