CSS text

You are currently viewing CSS text

CSS text is used to apply the different formatting in the text. HTML provides limited facilities for text formatting. CSS provides complete control on text formatting, presentation, and style.

Text Color

Text color is changed by specifying any color to color property. The color value can be specified as hexadecimal code like #00DDFF or a named color value like red as follows:

H1{
  color:red;
}
H1{
  color:#00DDFF;
}

Typeface

The typeface is used to specify the font-family of the text as follows:

H2{
  font-family:Verdana, Arial, Helverica, sans-serif;
}

The browser will keep going down the list of specified faces until it finds one that is installed on the system. If no font in the list is installed on the system, a font similar to the specified face will be used.

CSS Text size

CSS text can be used to specify the text size. HTML can display the text of size 7 at maximum. In CSS Text, the font-size property is used to specify the size of the text. The size can be specified by using different units that are as follows:

  • Units: points and pixels
  • Pre-defined keywords
  • Percentages

Size in Points

P{
  font-size:50pt;
}

Size in Pixels

P{
  font-size:43px;
}

To increase the font weight check this CSS Bold text article.

More Units

There are few other units of text-measurement that are Lexx widely used:

  • in is inches
  • cm is centimeters
  • mm is millimeters

keywords

There are seven keywords that work similarly to the values. The possible values are below:

p{
  font-size:large;
}
  • xx-small
  • x-small
  • small
  • medium
  • large
  • x-large
  • xx-large

Percentages

Percentage values are relative to the size of the parent value.

Body{
  font-size: 20pt;
}
P{
  font-size:200%;
}

In the above example, the font size of <body> is 20pt and font size of <p> is 200%. Any paragraph inside <body> will be sized 40pt.

Reference

If you want to learn more about CSS visit the official website: Visit

css text

Visit the CSS tutorial list. And make strong your CSS concept. Click here. wuschools.com is always written about the CSS concept for the CSS lover. Ang writes about how CSS makes your life easy if you are a web site developer. We help you to continue your learning.

Leave a Reply