cssmnemonics

CSS Mnemonics: How do you remember whether # or . is for class or id?


#test is the selector for id="test"

.test is the selector for class="test"

but how do you remember which way round they are (eg not .=id)


Solution

  • Well, in truth these things are so common that most people don't need mnemonics to remember them, but here's something I came up with, if it helps:

    In terms of a filename a . and then an extension denotes a type of thing. There can be many different things of this type. With CSS, using classes you can denote a single style for many elements of the same type.

    In terms of a URL, a # denotes an anchor link to a specific spot in the document. It refers to one location only. With CSS, using IDs you denote a single style for a single specific element.