I still new to CSS, and I was wondering if anyone here could point me in the right direction in regard to variations of styles.
If, for instance, I wanted to make a variation of the following style with a letter-spacing of 0.2em, how should I do that, and what should I put in the html tag?
p.text {
font-size: 0.75em;
text-align: left;
line-height: 1.8em;
letter-spacing: 0.1em;
font-family: sans-serif;
}
What I’ve done so far is make a new style based on the existing style, but I assume there’s a way of just varying the existing style.
2
Answers
Your HTML elements can have multiple classes, which can override styles. For example:
It’s common to make use of different classes, different specificity, or even just the order of rules applied to over-ride styles. In your browser’s development tools, take a look at the DOM Explorer and select an element (at least in Chrome), and you can see the multiple "layers" of CSS rules applied and which ones override others.
You can define a new class with only the properties you wish to change. Apply this new class alongside the original class directly in your HTML element.
CSS:
HTML with no spacing:
HTML with spacing: