Working With TextCSS
Working With TextCSS
<!DOCTYPE html>
<html>
<head>
<style>
p{
text-align: center;
color: red;
</style>
</head>
<body>
<p>And me!</p>
</body>
</html>
Letter Spacing
The letter-spacing property is used to specify the space between the
characters in a text.
h1 {
letter-spacing: 5px;
}
h2 {
letter-spacing: -2px;
}
Line Height
The line-height property is used to specify the space between lines:
p.small {
line-height: 0.8;
}
p.big {
line-height: 1.8;
}
Text Alignment
The text-align property is used to set the horizontal alignment of a text.
!DOCTYPE html>
<html>
<head>
<style>
h1 {
text-align: center;
h2 {
text-align: left;
h3 {
text-align: right;
}
</style>
</head>
<body>
<h1>Heading 1 (center)</h1>
<h2>Heading 2 (left)</h2>
<h3>Heading 3 (right)</h3>
<p>The three headings above are aligned center, left and right.</p>
</body>
</html>
Tip: You can combine more than one value, like overline and underline to
display lines both over and under a text.
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
text-decoration: overline;
h2 {
text-decoration: line-through;
h3 {
text-decoration: underline;
p.ex {
</style>
</head>
<body>
the reader.</p>
</body>
</html>
Text Transformation
The text-transform property is used to specify uppercase and lowercase
letters in a text.
It can be used to turn everything into uppercase or lowercase letters, or
capitalize the first letter of each word:
<!DOCTYPE html>
<html>
<head>
<style>
p.uppercase {
text-transform: uppercase;
p.lowercase {
text-transform: lowercase;
p.capitalize {
text-transform: capitalize;
</style>
</head>
<body>
</body>
</html>
Text Indentation
The text-indent property is used to specify the indentation of the first line of
a text:
<!DOCTYPE html>
<html>
<head>
<style>
p{
text-indent: 50px;
</style>
</head>
<body>
<h1>Using text-indent</h1>
</body>
</html>
CSS Selectors
CSS selectors are used to "find" (or select) the HTML elements you want to
style.