CSS Text

CSS Text

CSS provides several properties for styling text on web pages. Here are some common CSS text properties:

  1. color: This property is used to specify the color of text on a web page. You can use a color name, hexadecimal value, RGB or HSL value. For example:
h1 {
  color: #333;
}

In this example, we’re setting the color ofh1elements to a dark gray.

  1. text-align: This property is used to specify the horizontal alignment of text. You can use values such asleft,center, andright. For example:

In this example, we’re centering the text ofpelements.

  1. text-decoration: This property is used to add or remove decorations such as underline, overline, and line-through. For example:
a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

In this example, we’re removing the underline decoration from all links (aelements), and adding an underline decoration when the mouse hovers over the link.

  1. line-height: This property is used to specify the vertical spacing between lines of text. You can use a unit such as pixels or ems. For example:
p {
  line-height: 1.5em;
}

In this example, we’re setting the line height ofpelements to 1.5 times the font size.

  1. letter-spacing: This property is used to specify the spacing between characters. You can use a unit such as pixels or ems. For example:
h2 {
  letter-spacing: 1px;
}

In this example, we’re adding 1 pixel of spacing between characters inh2elements.

These are just a few of the many CSS text properties available for styling text on web pages.

Scroll to Top