Tag text-align

✏️ CSS text-align — Controlling Horizontal Alignment of Text

The text-align property in CSS controls the horizontal alignment of inline content, such as text, within a block-level element. It’s simple yet powerful — and one of the most commonly used styling tools in web design.


🔹 What Does text-align Do?

It determines how text and inline elements are aligned inside their container — left, right, center, or justified.


📘 Syntax

selector {
text-align: left | right | center | justify | start | end;
}

💡 Common Values

ValueDescription
leftAligns text to the left (default in LTR languages)
rightAligns text to the right
centerCenters the text inside the element
justifySpreads text across the full width, adjusting space between words
startAligns to the start of the reading direction (left in LTR, right in RTL)
endAligns to the end of the reading direction

✍️ Example: Centering a Paragraph

<p class="center-text">This text is centered using CSS.</p>
.center-text {
text-align: center;
}

🖼️ Image Idea: Visual Representation of text-align Values

Image Description:
A box showing a single line of text aligned:

  • To the left
  • To the right
  • In the center
  • With justified spacing

🎯 Purpose: Show how the alignment shifts inside the same width container.


🧠 Notes & Tips

  • text-align affects inline content only, such as:
    • Text
    • Inline images
    • Inline-block elements
  • It doesn’t move the block itself — only the content inside it.

✅ When to Use

Use CaseSuggested text-align
Paragraphs of readable contentjustify or left
Headlines or quotescenter
Navigation or sidebar widgetsright or center
RTL languages (Arabic, Hebrew)start or end

🔄 Interaction with Direction

html {
direction: rtl;
}

p {
text-align: start;
}
  • In RTL (right-to-left) languages, start aligns to the right.
  • end aligns to the left in RTL.

✨ Bonus: Centering Inline Elements

To center an inline element like a <span> or image inside a block:

.centered-block {
text-align: center;
}

Then:

<div class="centered-block">
<img src="image.png" alt="Centered image">
</div>

✅ Summary

Propertytext-align
Applies toInline content inside a block
ControlsHorizontal alignment of content
Useful forText, images, navs, buttons
Keywordsleftrightcenterjustifystartend

🔚 Final Thought

The text-align property is deceptively simple — but it’s crucial for creating visually balanced, readable contentacross languages and layouts. Mastering it brings clarity and professionalism to your designs.