Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Thanked 0 Times in 0 Posts

    difference b/w id & class selectors?

    Does anybody know what's the difference b/w an id selector and a class selector? I know id selector uses (#) in front of it, and class selector uses (.) in front of it, but is the difference in their usage? Thanks!

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Splendora, Texas, United States of America
    Thanked 293 Times in 287 Posts
    IDs (identities) are used to identify a single element. Classes (classifications) are used to identify groups of objects. Essentially only one element on a page can have a particular ID while classes can be applied to multiple elements. Think of it like people: there are individual people each with their own unique ID and then there are classes of people, by nation, by school, by occupation, etc.

    Example: There can only be one total page container so you might assign that an ID. You might have five data tables and you want all of them to have the same font so you could mark them with the same class.

    You can also define multiple classes for an object like so:
    <span id="thankyoumessage" class="japanesetext specialcolor">Arigatou!</span>
    For every complex problem, there is an answer that is clear, simple, and wrong.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts