CLASSES AND IDS
Classes and ids find their greatest usage in conjuction with divs and spans. Defining attributes in css and then applying them at will to html tags is a powerful way to design a site. There is only one main difference between the two: An id can only be used once and classes can be used as often as you could ever desire.Though divs and spans become the main location for classes and ids, they can actually be applied to just about any html tag out there, including <p>, <table>, <h1> through <h6>, <ol> and <ul>, etc. Class/ids can also be specifically assigned to a particular tag, for example:
p#first{
color:#000;
font-family:arial, helvetica, sans-serif;
font-size:13px;
}
This then creates an id titled first with the above attributes. It can only be applied to the p tag. To be able to apply it to any tag, it would be written as follows:
#first{
color:#000;
font-family:arial, helvetica, sans-serif;
font-size:13px;
}
The difference in writing a class and an id is that a class begins with a period, like this:
.first{
color:#000;
font-family:arial, helvetica, sans-serif;
font-size:13px;
}
As one last example of classes and ids, a couple from this site itself will be listed, which are also mentioned in the div/span section.
#content {
background:#000;
position:absolute;
top:188px;
left:275px;
width:500px;
font-family:arial, helvetica, sans-serif;
font-size:13px;
}
.codetext {
color:#ffb44c;
}
The content id designs the central area of the site that contains all of the main, changing content. The class codetext is used when changing the color of the text within the content area. Viewing the source code of this site will give a more indepth look at the application of these.