OK, I was trying to avoid this thread because it can lead down a rabbit hole I don’t really have the time to delve into, but it seems to have gotten away from the original question.
The basic difference between ID and class is there should only be one instance of an id on a page, but there can be multiple instances of class. Note the emphasis on should in the previous sentence. All of the browsers ALLOW you to use more than once instance of an id, but that’s not the way it’s supposed to work.
So you should never have this markup (from one of your previous posts)
#wrapper_details span#authorName{ }
#wrapper_store span#authorName{ }
#wrapper_cart span#authorName{ }
#wrapper_freebook span#authorName{ }
Now this is where the true power of CSS comes into place IF you plan it right. You need to get away from the concept of pixel perfection and allow yourself to think in relative measures and in terms of content instead.
So instead of
- In details, I want the Authors Name to be 16px and the published date 14px
- In the store, I want the Authors Name to be 12px and the published date 10px
- In the card, I want the Authors Name to be 10px and the published date 8px
- In freebook, I want the Authors Name to be 14px and the published date 12px
You think something like this
I would like to see the Authors Name be 10% bigger and the Published Date 10% smaller than the rest of the text in the details, store, cart and freebook sections
And to do that you would use simple classes for the author and the published date
.authorName { font-size: 1.1rem; } /* or 110%; */
.publishedDate { font-size: .9rem; } /* or 90%; */
Then you would just set a base font-size in each of the wrappers
#wrapper_details { font-size: 16px; }
#wrapper_store { font-size: 12px; }
#wrapper_cart { font-size: 10px; }
#wrapper_freebook { font-size: 16px; }
or even better, allow the user to choose the base font size and adjust accordingly…
#wrapper_details { font-size: 1em; }
#wrapper_store { font-size: .8em; }
#wrapper_cart { font-size: .75em; }
#wrapper_freebook { font-size: 1em; }
The font size for the author and published date spans will be adjusted based on the font size of the wrappers. This keeps a consistent ratio for the same type of data across the board, which will be easier for you as it’s less to maintain, and for your customers as you’re providing a consistent experience.