Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

CSS: Differences between Class and ID

Posted on 2011-10-18
4
Medium Priority
?
190 Views
Last Modified: 2012-05-12
What are the differences in usability between defining the CSS is a Class versus an ID?

Thanks.
0
Comment
Question by:newbieweb
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 36989935
'class' is intended to used for styling multiple elements on a page with the same style rules.  'id' is supposed to be unique on a page.  'id' is used by javascript to 'identify' specific elements.  If you duplicate an 'id' on a page, you can find that your javascript doesn't do what you though it would.
0
 

Author Closing Comment

by:newbieweb
ID: 36989939
Got it!
0
 
LVL 61

Expert Comment

by:HainKurt
ID: 36989974
sample

<style>
.classStyle {....}
#idStyle {...}
</style>

<div class=classStyle>...</div>
<table class=classStyle>...</table>
<p id=idStyle>...</p>

we applied same class to 2 different element and applied a style to a special element by defining the id in style
0
 

Author Comment

by:newbieweb
ID: 36989978
thanks.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question