19/07/2016

CSS Text

In CSS it is possible to manipulate the text used in the webpage with the help of text properties. 

Below are the various text properties which can be applied to any HTML element -

Text Color

The color property is used to set the color of the text. 
h1 
{
	color: #336699;
}

To define the default color of the text we use the body selector:
body 
{
	color: blue;
}

Text Alignment

The text-align property is used to set the alignment of text horizontal. 
h1 
{
	text-align: left;
}

The posible values for this property are:
ValueDescription
leftAligns the text to the left
rightAligns the text to the right
centerCenters the text
justifyStretches the lines so that each line has equal width (like in newspapers and magazines)
initialSets this property to its default value.
inheritInherits this property from its parent element.

Text Decoration

The text-decoration property is used to set or remove decorations from text (like removing underlines from links etc).
a 
{
    text-decoration: none;
}

The posible values for this property are:
ValueDescription
noneDefines a normal text. This is default
underlineDefines a line below the text
overlineDefines a line above the text
line-throughDefines a line through the text
initialSets this property to its default value.
inheritInherits this property from its parent element.

Text Transformation

The text-transform property is used to turn the selectd text into uppercase, lowercase letters or capitalizing the first letter of each word.
h1
{
	text-transform: uppercase;
}
h3
{
	text-transform: lowercase;
}
h3
{
	text-transform: capitalize;
}

Text Indentation

To specify the indentation of the first line of a text, CSS has "text-indent" property.

p 
{
	text-indent: 25px;
}

All Text Properties

Below are the all CSS Text properties:

PropertyDescription
colorSets the color of text
directionSpecifies the text direction/writing direction
letter-spacingIncreases or decreases the space between characters in a text
line-heightSets the line height
text-alignSpecifies the horizontal alignment of text
text-decorationSpecifies the decoration added to text
text-indentSpecifies the indentation of the first line in a text-block
text-shadowSpecifies the shadow effect added to text
text-transformControls the capitalization of text
unicode-bidiUsed together with the direction property to set or return whether the text should be overridden to support multiple languages in the same document
vertical-alignSets the vertical alignment of an element
white-spaceSpecifies how white-space inside an element is handled
word-spacingIncreases or decreases the space between words in a text