kristi9 Posted February 21, 2009 Share Posted February 21, 2009 hi evereyone, I am new to CSS Please tell me what is the difference between an ID and a class? Thanks --------------------------------- Software development company Web application development Quote Link to comment Share on other sites More sharing options...
POG1 Posted February 21, 2009 Share Posted February 21, 2009 Re: What is the difference between an ID and a class? An id is something to be unique. Classes are something to be used over and over. Quote Link to comment Share on other sites More sharing options...
Floydian Posted February 21, 2009 Share Posted February 21, 2009 Re: What is the difference between an ID and a class? POG1 one pretty much summed it all up. There's another thing I'd add to that, which is: You can only have one id on an element. You can have any number of classes on an element. For instance, suppose you make a class for bolding text, aligning text, and another one for making text small. You could apply those like this: <style> .bold { font-weight: bold; } .left { text-align: left; } .small { font-size: 9px; } </style> <p class="bold left small">...............................</p> Quote Link to comment Share on other sites More sharing options...
POG1 Posted February 21, 2009 Share Posted February 21, 2009 Re: What is the difference between an ID and a class? Here is a simple example of how classes could be used with ids. <style type="text/CSS"> .box { border:1px solid #FFFF99; background: #FFFF33; } #skinny { width:80px; } #wide { 800px; } </style> <div id="skinny" class="box"> skinny? </div> <div id="wide" class="box"> wide =) </div> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.