|
Search This Site
|
Styling Text With CSS
Color Property The color property is one of the most often used properties in CSS. It is used to set the color of your text and can be used like this:
p
{
color: red; <------ color property and value set to style paragraphs
}
style.css
#red-shade
{
color: #B80000;
}
style.css
#red-shade
{
color: rgb(184,0,0);
}
Text-Align PropertyThe text-align property is used to center text. It can also be used to align the text to the left, right and even to justify the text.
text-align: center; <------ text-align property with the center value
style.css
h5
{
text-align: center;
}
The above center aligns any text placed between the level 5 heading tag in any document referencing this style sheet.
Try changing the center value to left, right and justify to see the corresponding result. Text-Indent PropertyWhenever you start a new paragraph, it's not uncommon to have the first line of that paragraph begin some distance away from the margin. The text-indent property serves to provide an indent to the first line of text. The value for this property should be specified in pixels. The format:
text-indent: 37px; <----- paragraph set to begin 37 pixels from the margin
style.css
p
{
text-indent: 37px;
}
Text-Transform Property The text-transform property sets the text to contain all capital letters ( CAPS ),
all common ( no caps ) or to have the first letter of every word capitalized (Like This).
The values for this property are: uppercase , lowercase and capitalize .
The text-transform property is applied like this:
text-transform: uppercase; <----- text-transform property set to display all CAPS
style.css
.capit
{
text-transform: capitalize;
}
Text-Decoration PropertyWith the text-decoration property you can underline text. If you have a link, you can use this property to remove the default line that you normally see under it. The values of the text-decoration property are the underline , line-through , overline and none . The format follows:
text-decoration: line-through; <----- This will put a line through the text
h4
{
text-decoration: line-through;
}
Experiment with the other values for yourself and see the effect it has on the heading.
Previous Lesson - Div & Span
Next Lesson - Fonts
|
|
© Copyright 2010 | All Rights Reserved
|