CSS text

TEXT FORMATTING

Text formatting

This text is styled with some of the text formatting properties. The heading uses the text-align, text-transform, and color properties. The paragraph is indented, aligned, and the space between characters is specified. The underline is removed from this colored "Try it Yourself" link.

This text uses some text formatting attributes to set the style. The heading uses the text-align, text-transform, and color properties. The paragraph is indented, aligned, and the space between characters is specified. Then from this colorful“Try it Yourself”The underline is removed from the link.

Prova själv

Text color

color The attribute is used to set the text color. The color is specified by the following values:

  • Color name - for example "red"
  • Hexadecimal value - for example "#ff0000"
  • RGB-värden - till exempel "rgb(255,0,0)"

Se CSS färgvärdenför att få en fullständig lista över möjliga färgvärden.

Sidoras standardtextfärg definieras i body-väljaren.

Exempel

body {
  color: blue;
}
h1 {
  color: green;
}

Prova själv

Tips:För W3C-kompatibla CSS: Om du definierar color egenskap, måste du också definiera background-color egenskaper.

textfärg och bakgrundsfärg

I detta exempel har vi definierat background-color Egenskaper och color Egenskap:

Exempel

body {
  background-color: ljusgrå;
  color: blue;
}
h1 {
  background-color: black;
  color: white;
}

Prova själv