html
/

CSS Text

Last Sync: Today

On this page

13
0%
5 min read
Remaining
5 minleft

Click any section to jump — progress syncs automatically

html

CSS Text

What is CSS Text?

CSS text properties are used to style and format text, including alignment, spacing, decoration, and transformation.

Text Color

CSSRead-only
1
p {
  color: blue;
}

Text Alignment

CSSRead-only
1
p {
  text-align: center;
}

Text Decoration

CSSRead-only
1
a {
  text-decoration: none;
}

h1 {
  text-decoration: underline;
}

Text Transformation

CSSRead-only
1
p {
  text-transform: uppercase;
}

Text Spacing

CSSRead-only
1
p {
  letter-spacing: 2px;
  word-spacing: 5px;
  line-height: 1.5;
}

Text Indent

CSSRead-only
1
p {
  text-indent: 20px;
}

Text Shadow

CSSRead-only
1
h1 {
  text-shadow: 2px 2px 5px gray;
}

White Space

CSSRead-only
1
p {
  white-space: nowrap;
}

Common Text Properties

PropertyDescription
colorText color
text-alignAlignment
text-decorationUnderline/none
text-transformUppercase/lowercase
letter-spacingSpace between letters
line-heightLine spacing

Best Practices

  • Maintain good contrast for readability
  • Use consistent spacing and alignment
  • Avoid excessive text shadows
  • Use proper line-height for readability

Common Mistakes

  • Poor color contrast
  • Overusing uppercase text
  • Too much letter spacing
  • Ignoring readability on mobile

Conclusion

CSS text properties help improve readability and design. Proper text styling enhances user experience.

Try it yourself

p {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
}

Test Your Knowledge

Q1
of 3

Which aligns text?

A
text-align
B
text-style
C
align
D
font-align
Q2
of 3

Which changes case?

A
text-case
B
text-transform
C
font-style
D
uppercase
Q3
of 3

Which controls spacing between lines?

A
letter-spacing
B
line-height
C
word-spacing
D
text-indent

Frequently Asked Questions

What does text-align do?

Aligns text horizontally.

What is text-transform?

Changes text case (uppercase/lowercase).

What improves readability?

Proper spacing, contrast, and line height.

Previous

css box model

Next

css fonts

Related Content

Need help?

Explore our comprehensive docs or start a chat with our tech experts.