Selector by id and CSS classes
One element can be assigned both id
and classes. In this case, part of the element's styles can be set via id
, and part of the styles via the class:
<div id="block" class="large">
<p>text</p>
<p>text</p>
</div>
#block {
color: red;
font-family: Arial;
}
.large {
font-size: 30px;
}
Style the blocks by id
and by class:
<div id="block" class="text">
<p>text</p>
<p>text</p>
<p>text</p>
</div>
<div class="text">
<p>text</p>
<p>text</p>
<p>text</p>
</div>