Introduction
Good text styling makes a website more interesting and easier to read. This article will show you how to use CSS, the language for designing web pages, to make your text look great. Whether you’re new to web design or looking to brush up on your skills, this guide will help you understand the basics and a bit more about typography and text styling in CSS.
These are the most common and commonly used styles in CSS. We will learn about the following:
- Font Family
- Font Size
- Font Weight
- Font Style
- Text Decoration
- Text Transform
- Text Align
- Line Height
- Letter Spacing
- Word Spacing
- Text Indent
- Text Shadow
Lets discuss each of these in detail
1. Font Family
The font-family property in CSS is all about picking the right font for your text. It’s like choosing the right outfit for an occasion. You can pick one main font and have a few backups just in case the first one doesn’t work.
|
|
Here, if ‘Calibri’ isn’t available, the browser will try ‘Arial’, and if that’s not there, it will use a default sans-serif font.
2. Font Size
The font-size property in CSS is used to set the size of the text. You can use any unit you want. The default font size is 16px
.
|
|
3. Font Weight
The font-weight property controls the thickness or boldness of the text. It can be set to values like normal, bold, or numeric values like 400, 700, etc. For example:
|
|
4. Font Style
The font-style property controls the style of the text. It can be set to values like normal, italic, or oblique. For example:
|
|
5. Text Decoration
The text-decoration property controls the decoration of the text. It can be set to values like underline, overline, or line-through. For example:
|
|
6. Text Transform
The text-transform property controls the case of the text. It can be set to values like uppercase, lowercase, or capitalize. For example:
|
|
7. Text Align
The text-align property controls the alignment of the text. It can be set to values like left, right, center, or justify. For example:
|
|
8. Line Height
The line-height property controls the spacing between lines of text. It can be set to values like 1, 1.5, or 2. For example:
|
|
9. Letter Spacing
The letter-spacing property controls the spacing between letters. It can be set to values like 0, 0.5, or 1. For example:
|
|
10. Word Spacing
The word-spacing property controls the spacing between words. It can be set to values like 0, 0.5, or 1. For example:
|
|
11. Text Indent
The text-indent property controls the indentation of the first line of text. It can be set to values like 0, 1em, or 2em. For example:
|
|
12. Text Shadow
The text-shadow property controls the shadow of the text. It can be set to values like 0 0 5px black, 0 0 10px black, or 0 0 15px black. For example:
0
is the horizontal offset, 0
is the vertical offset, 5px
is the blur radius, and black
is the color.
|
|
13. Word Wrap
The word-wrap property controls the wrapping of the text. It can be set to values like normal, break-word, or nowrap. For example:
|
|
|
|
14. Text Overflow
The text-overflow property controls the overflow of the text. It can be set to values like clip, ellipsis, or none. For example:
|
|
The HTML element will be clipped if it overflows its container.
|
|
Conclusion
Typography and text styling in CSS are key to making websites that are easy to use and look good. By understanding these CSS properties, you can make sure your text does its job well. Remember, the goal is to make your website not just look nice, but also be easy and enjoyable to read. Keep practicing, and you’ll be a pro at web typography in no time!
Happy coding! 🚀