#top {
background-color: #cccccc;
}
.intro {
color: red;
}
The HTML refers to the CSS by using the attributes id and class. It could look something like as follows.
<div id="top">
<p class="intro">This is my text.</p>
</div>
The difference between an ID and a class is that an ID can be used to identify one element, whereas a class can be used to identify more than one. You can also apply a selector to a specific HTML element by simply stating the HTML selector first, so p.desc will only be applied to paragraph elements that have the class 'desc'.
No comments:
Post a Comment