Difference beween class and id-selector.

Reply

Join Date: Jun 2005
Posts: 104
Reputation: Pim is an unknown quantity at this point 
Solved Threads: 0
Pim Pim is offline Offline
Junior Poster

Difference beween class and id-selector.

 
0
  #1
Feb 21st, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 434
Reputation: FC Jamison is on a distinguished road 
Solved Threads: 20
Team Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: Difference beween class and id-selector.

 
0
  #2
Feb 21st, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC