Building a Resume Class vs. ID


So I am working on the build a resume project...

Why would we use a class for left and right and ids for footers.... what is the difference and the reason for using either class or id??


There is no hard and fast rule about which to use. Each situation presents with its own challenges. A class is most useful when sharing style rules across a range of selectors. One style rule, many applications of the rule throughout the document.

When we want to single out one specific element for special treatment then id is appropriate. We can only give an id to a single element, and it must be unique in the page. It cannot be applied to multiple elements in the same document.

For now, don't give this too much importance just yet. Focus on the structure and syntax of the basic HTML document and the more practical aspects of class and id will reveal itself with time and practice.


Examining the #footer element:


#footer {



<div id="footer">


The uniqueness does not restrict this element from having child elements that share a class with the rest of the document. Say for instance the document has two special classes, .left and .right. The #footer can have those classes, but can also modify them. These modifications will only apply to the footer:


.left {

.right {

#footer .left {

#footer .right {


There are lots of other ways to explore using an id on a parent element. The ability to modify classes is one we will use a lot. It also ups the specificity on all elements it contains when the id selector is included in a the selector rule. Note that,

.left     -->  0 0 1 0
#footer   -->  0 1 0 0
combinator ->  0 1 1 0

The concepts of the cascade, inheritence, specificity and importance are intrinsic to the core of CSS and worth the time it takes to read up on and study them. We do need to know this stuff in the real world of HTML and CSS. Start to learn it now, and keep up your studies over time to keep fresh and pick up new insights.

CSS is an artful skill, not just a programming skill. The better we understand the mechanics the more creative we can be with our designs.



@mtf is right but also,

Classes are generally used multiple times while Id's are unique and should be used once, that's what I learnt...