-
Hajipur, Bihar, 844101
CSS provides various properties to style and format text content. These include alignment, decoration, transformation, spacing, and more to enhance readability and presentation.
Property | Description |
---|---|
color |
Sets the color of the text |
text-align |
Aligns text (left, right, center, justify) |
text-decoration |
Adds or removes decorations (underline, etc.) |
text-transform |
Controls capitalization (uppercase/lowercase) |
letter-spacing |
Sets spacing between characters |
word-spacing |
Sets spacing between words |
line-height |
Sets space between lines |
text-indent |
Indents the first line of text |
direction |
Defines the text direction (LTR/RTL) |
white-space |
Controls how whitespace is handled |
<p class="styled-text">This is styled text using multiple text properties.</p>
.styled-text {
color: darkblue;
text-align: center;
text-decoration: underline;
text-transform: uppercase;
letter-spacing: 2px;
word-spacing: 4px;
line-height: 1.8;
}
text-align
text-align: left | right | center | justify;
Example:
p {
text-align: justify;
}
text-decoration
text-decoration: none | underline | overline | line-through;
Example:
a {
text-decoration: none;
}
text-transform
text-transform: uppercase | lowercase | capitalize;
Example:
h2 {
text-transform: capitalize;
}
letter-spacing
and word-spacing
letter-spacing: 1px;
word-spacing: 5px;
line-height
line-height: 1.5; /* Ideal readability */
text-indent
p {
text-indent: 50px;
}
🟢 Indents the first line of the paragraph.
white-space
white-space: nowrap | pre | pre-wrap | normal;
Used to control how spaces and line breaks are handled.
Q1. Center-align a paragraph.
Q2. Underline all <h3>
headings.
Q3. Make all text in a .title
class uppercase.
Q4. Add 5px space between letters in a paragraph.
Q5. Create double line spacing using line-height
.
Q6. Remove underline from all <a>
links.
Q7. Indent the first line of a paragraph by 40px.
Q8. Add 10px space between words.
Q9. Align a heading to the right.
Q10. Capitalize the first letter of each word in a heading.
Q1: Which property aligns text to the center?
Q2: Which value makes all letters capital?
Q3: Which property adds space between characters?
Q4: What does text-decoration: none do?
Q5: Which property is used to indent the first line of text?
Q6: Which value of text-transform capitalizes each word’s first letter?
Q7: What does line-height: 2; mean?
Q8: Which property adjusts space between words?
Q9: What does white-space: nowrap; do?
Q10: Which property draws a line through the text?