943,950 Members | Top Members by Rank

Ad:
Feb 21st, 2008
0

Difference beween class and id-selector.

Expand Post »
What does it matter wheater I use:
HTML and CSS Syntax (Toggle Plain Text)
  1. p.center
  2. {
  3. text-align: center;
  4. }
And HTML:
HTML and CSS Syntax (Toggle Plain Text)
  1. <p class="center">
  2. Text.
  3. </p>

Or I use:
HTML and CSS Syntax (Toggle Plain Text)
  1. #paragraphs p
  2. {
  3. text-align: center;
  4. }
And then HTML:
HTML and CSS Syntax (Toggle Plain Text)
  1. <div id="paragraphs">
  2. <p>
  3. Text.
  4. </p>
  5. </div>

Could somebody explain please?

Thank You.
Pim
Reputation Points: 10
Solved Threads: 0
Junior Poster
Pim is offline Offline
106 posts
since Jun 2005
Feb 21st, 2008
0

Re: Difference beween class and id-selector.

The difference is that an ID references a unique element on the page...i.e. there is only one element on the whole page with the ID.

A class can be used to name several different elements on the page.

In other words, you can have one div with a specific ID, but multiple divs with a specified class.

In your case, you would probably want to use a class.
Team Colleague
Reputation Points: 92
Solved Threads: 21
Posting Pro in Training
FC Jamison is offline Offline
436 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: rollover effect
Next Thread in HTML and CSS Forum Timeline: Nav bar in dreamweaver dissappears after click





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC