CSS can be used to style text by changing the font, color, size, weight, spacing, alignment, and more.
HTML Tags
HTML provides a few tags that are used to give text special meaning and the browser will often style this text differently depending on what tag is used. These tags are more for marking up text in a semantic way so that the browser understands the meaning of each section of text.
Below are a few of the HTML tags most often used.
This text is bold.
This text is important!
This text is italicized.
This text is emphasized.
This text is underlined because it is missspelled.
This is some smaller text.
These tags are not meant to exist on their own. They are meant to be placed within heading tags or paragraph tags.
This text is important!
Styling Text with CSS
Below are several examples of stying text using CSS. They include setting the text color, font-size, font-weight, font-style, text-alignment, and text-transform.
/* all headings will have red, bold text */
h1, h2, h3, h4, h5, h6 {
color: red;
font-weight: bold;
}
/* all paragraphs will have a font size of 18px; */
p {
font-size: 18px;
}
/* text with the class .our_mission will be italicized and centered
in its parent element */
.our_mission {
text-align: center;
font-style: italic;
}
/* text within the HTML small tag will be 80% as big as its parent
element text, green, and transformed to all uppercase */
small {
color: green;
font-size: 80%;
text-transform: uppercase;
}
Text Properties
- CSS – color Property
- CSS – font-style Property
- CSS – font-variant Property
- CSS – font-weight Property
- CSS – letter-spacing Property
- CSS – line-height Property
- CSS – text-align Property
- CSS – text-decoration Property
- CSS – text-indent Property
- CSS – text-shadow Property
- CSS – text-transform Property
- CSS – word-spacing Property
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.
Why 1SMARTchicken?
See More →
Thanks for your support!
CSS Books
All are affiliate links. Thank you for your support!
CSS NOTES:
- The “inherit”, “initial” and “unset” keywords can be used with any CSS property to set its value
- In CSS there are many ways to express a color value in a property
Feedback
If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.