Reputation: 97
I want to use one class for two different tags. Do I have to declare it like <h1 class="line">
and then <p class="line"
> ??? and in the CSS would it just be .line
and it would change it for both then? Please help. Thanks
Upvotes: 0
Views: 532
Reputation: 22977
You need to declare the class within your CSS:
.line {
background-color: red;
}
And then you can apply the class to your HTML elements:
<tag1 class="line" />
<tag2 class="line" />
Upvotes: 2
Reputation: 9520
Easy: just use the same class for several different elements. E.g.:
HTML:
<div class="line">
Lorem ipsum...
</div>
<p class="line">
Blah blah blah
</p>
CSS: for example, give each element with the .line
class a red border:
.line {
border: 1px solid red;
}
See the jsfiddle!
Upvotes: 1