0
How can i use class for font family and font size in a paragraph in HTML and reference them in CSS for styling?
2 Antworten
+ 1
If what you are asking is how to assign a class to an element, and then reference that element in CSS:
Insert an ID inside the opening tag of an element, then reference that in CSS, like so:
HTML
<p id="turtle">This element now has an id of turtle.</p>
CSS
#turtle {
font-size: small
}
+ 1
If you want to create a reusable item in the css, use a class. Ids should be unique.
HTML
<p class="sampleFont">This paragraph will have the class sampleFont applied.</p>
CSS
.sampleFont {
font-family: Arial;
font-size: 25px;
}