Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS Help, Confused on using # instead of . 1

Status
Not open for further replies.

jmiller79

Programmer
Jul 13, 2004
48
US
I am brand new to CSS and I am very confused, maybe someone can help me. I bought a book to help, and I noticed that inside of the HTML <style> tag you use the “div#” and sometime you use “div.”. What is the difference, and when do you use one appose top the other. For example

Example 1
<style>
div#summary {font-weight: bold;}
</style>

Example 2
<style>
div.release {font-weight: bold;}
</style>


Thanks in advance,
 
First is the id, second is the class. In html code, it would look like this:
Code:
<div id="summary"></div>
<div class="release"></div>
From CSS standpoint, there is no difference between classes and ids. However, HTML allows for only one instance of unique id per page, meaning you cannot have two elements with the same id. Classes have no such restriction. JavaScript can easily access elements with id, while there is no equivalent for accessing elements with the class. That's basically the difference.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top