In CSS, what is the difference between .btn and #btn?
Options
- There is no difference between the two selectors
.btntargets a class (many);#btnan id (one) (Correct option)#btntargets only the button elements of a page.btnis not a valid selector in modern CSS
Answer
.btn targets elements with class="btn" (can be many); #btn targets the element with id="btn" (should be unique)
Why
A class (.) is a reusable label: many elements can share class="btn".
An id (#) should identify exactly one element per page.
For styling, classes are preferred: IDs have very high specificity, which makes them hard to override later.
Remember
. = class (many), # = id (one).