#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
CSS3 Fundamentals

CSS3 Text

CSS text properties control how lines of text are aligned, spaced, decorated, transformed and wrapped. They are separate from font properties, which choose the typeface, size and weight. Getting text properties right is what makes a page comfortable to read, especially on narrow phone screens.

Alignment and line spacing

text-align sets horizontal alignment inside a block: left, right, center, justify, or the direction-aware start and end. Justified text can leave uneven gaps on small screens, so use it with care.

line-height sets the height of each line. A unitless value such as 1.6 is best, because it scales with the font size of each child. A fixed value such as 24px is inherited as is, which can make larger headings overlap.

letter-spacing and word-spacing adjust the gaps between characters and words. Small positive letter spacing helps uppercase labels look less cramped.

Decoration, transform and indent

text-decoration adds or removes underlines, overlines and strike-throughs. CSS3 lets you style them in detail with text-decoration-color, text-decoration-thickness and text-underline-offset. text-transform changes letter case to uppercase, lowercase or capitalize without editing the HTML. text-indent pushes the first line of a paragraph inward.

article p {
  line-height: 1.6;
  max-width: 65ch;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
}

a {
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.card-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

h1 {
  text-shadow: 0 2px 6px rgb(0 0 0 / 0.35);
}

Handling long text and overflow

white-space controls whether spaces collapse and lines wrap. nowrap keeps text on one line, while pre-wrap preserves spaces and line breaks from the source.

text-overflow: ellipsis shows "..." when text is cut off. It only works when three conditions are met together: the text cannot wrap (white-space: nowrap), the box hides overflow (overflow: hidden), and the element has a limited width. Missing any one of these is the usual reason the ellipsis never appears.

Long URLs or email addresses can push a layout wider than the screen on mobile. overflow-wrap: anywhere lets the browser break them at any point to stay inside the container.

A readability mistake

Using text-transform: uppercase on whole paragraphs makes text noticeably harder to read and sounds like shouting. Keep it for short labels. Similarly, avoid removing link underlines unless links stand out clearly some other way, because colour alone is not enough for everyone. And because text-transform only changes appearance, text copied by users keeps its original case.

Vertical alignment is a separate topic from text alignment. text-align only moves content left and right inside its line box. To centre text vertically inside a box, use flexbox with align-items: center on the container, or for single inline elements next to icons, vertical-align: middle.

Text shadow

text-shadow takes horizontal offset, vertical offset, blur and colour. A soft dark shadow helps white headings stand out on photos, but heavy shadows on body text look blurry.

What to take away

Use a unitless line height, keep line length near sixty-five characters with max-width: 65ch, and remember the three-part recipe for ellipsis truncation.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course