servermanfail servermanfail - 1 year ago 94
CSS Question

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

is the selector for

is the selector for

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download