Tutorials
CSSIn this tutorial you will learn about Cascading Style Sheets (CSS), Text, Text color, Text background color, Text direction, Text align, Text indent, Text transform, Text decoration, Letter spacing and Word spacing.
To set the text color, use the “color” property.
p
{
color: #FF0000;
}
h1
{
color: red;
}
This sets the HTML element < p > and the HTML element < h1 > to red.
To set the background color of an element, use the property “background-color”, this property was explained in CSS background lesson.
To set the text direction, use the “direction” property, it can take one of two values:
body
{
direction: rtl;
}
This sets the text direction of the whole document to be from right to left.
to align the text contained in an element to the element, use the property “text-align”, this property can take one of the following values:
left, right, center, or justify.
P
{
text-align: right;
}
This aligns the element < p > text to the right of the element that it's contained in.
To indent the first line of a text, use the “text-indent” property, the value can be an absolute length, or a percentage value.
P
{
text-indent: 15px;
}
This indents the first line of the HTML element < p > 15 pixels.
To set the text letters case, use the property “text-transform”, this property can have one of the following values:
P
{
text-transform: lowercase;
}
This sets all the < p > element text characters to be in lowercase.
To set the text decoration, use the property “text-decoration”, it can have one of the following values:
.underline
{
text-decoration: underline;
}
This causes any text element that uses this class to be underlined.
To increase or decrease the space between characters, use the property “letter-spacing”, it can have one of the following values:
Body
{
letter-spacing: 1px;
}
This sets the space between all characters in the document to 1 pixel.
To increase or decrease the space between words, use the property “word-spacing”, it can have one of the following two values:
P
{
word-spacing: 2px;
}
This sets the space between all words in the document to 2 pixels.