1. css
  2. /text

CSS Text Property

Introduction

The text property is a shorthand property in CSS that allows you to set multiple text-related properties in a single declaration. It allows you to control the appearance and formatting of text on a web page, such as font size, font family, font style, text alignment, and text decoration.

Basic Usage

To use the text property, you specify the values for the text-related properties you want to set, separated by spaces. Here is an example of using the text property to set the font size, font family, and font style of an element:

.my-element {
  text: 16px Arial italic;
}

In the example above, we are setting the font size of the .my-element class to 16 pixels, the font family to Arial, and the font style to italic.

Order of Values

The order of the values you specify for the text property is important. The first value is always the font size, followed by the font family, and then the other text-related properties in the following order:

  1. font style
  2. font weight
  3. font variant
  4. font stretch
  5. font size-adjust
  6. font feature-settings
  7. font language-override
  8. text-decoration-line
  9. text-decoration-style
  10. text-decoration-color
  11. text-transform
  12. text-orientation
  13. text-combine-upright
  14. text-indent
  15. text-align-last
  16. line-height
  17. letter-spacing
  18. word-spacing
  19. text-decoration
  20. text-emphasis-style
  21. text-emphasis-color
  22. text-emphasis-position
  23. text-emphasis
  24. text-shadow
  25. text-outline
  26. text-wrap
  27. text-overflow
  28. text-overflow-ellipsis
  29. text-overflow-mode
  30. white-space
  31. word-break
  32. word-wrap
  33. hyphens
  34. tab-size
  35. orphans
  36. widows
  37. font-kerning
  38. font-variant-ligatures
  39. text-align
  40. text-justify

Here is an example of using the text property to set multiple values in the correct order:

.my-element {
  text: 16px Arial italic normal normal normal none underline solid #333 none uppercase normal none none none none