| | |
Difference beween class and id-selector.
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2005
Posts: 104
Reputation:
Solved Threads: 0
What does it matter wheater I use:
And HTML:
Or I use:
And then HTML:
Could somebody explain please?
Thank You.
HTML and CSS Syntax (Toggle Plain Text)
p.center { text-align: center; }
HTML and CSS Syntax (Toggle Plain Text)
<p class="center"> Text. </p>
Or I use:
HTML and CSS Syntax (Toggle Plain Text)
#paragraphs p { text-align: center; }
HTML and CSS Syntax (Toggle Plain Text)
<div id="paragraphs"> <p> Text. </p> </div>
Could somebody explain please?
Thank You.
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.
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.
![]() |
Other Threads in the HTML and CSS Forum
- Previous Thread: rollover effect
- Next Thread: Nav bar in dreamweaver dissappears after click
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7





