Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between text-align: end and right

What is the difference between text-align: end; and text-align: right;?

When I use either one I get the same result, but is there any differences?

like image 822
Brian Nezhad Avatar asked Jan 09 '16 19:01

Brian Nezhad


People also ask

What are 3 different ways we can align text?

A text can be left or right aligned, centered, or justified.

What is the difference between left and right aligned text?

Left-aligned text is text that is aligned with a left edge. Right-aligned text is text that is aligned with a right edge. Centered text is text that is centered between two edges.

What aligns the right end of the text?

The line is left-aligned by default. Click to the left of the text you want to right align. For this example, click to the left of “right-aligned,” and press Tab.

What does it mean to right align text?

Right align, right alignment, or right justify is text or page formatting that aligns text along the right side of a page or containing element.

What's the difference between text alignment and text direction?

text-align: right instructs the browser to align the text to the right side of the container. direction: rtl instructs the browser how the text is displayed, either from left to right or right to left. Some countries write from right to left (as opposed to left to right as you are probably used to).

What are the different types of text-align?

There are 4 types of text alignments which are left-aligned, center-aligned, right-aligned, and justified.


2 Answers

According to https://developer.mozilla.org/en/docs/Web/CSS/text-align:

  • end
    The same as right if direction is left-to-right and left if direction is right-to-left.

  • right
    The inline contents are aligned to the right edge of the line box.

Basically you use end in tandem to direction: [rtl|ltr] and end will adjust accordingly, whereas right will always keep your text to the right no matter what direction you set.

https://jsfiddle.net/ths4kdmx/

.end {
  text-align: end;
}
.right {
  text-align: right;
}
.dir-ltr {
  direction: ltr;
}
.dir-rtl {
  direction: rtl;
}
<div class="dir-ltr end">
  End alignment in left-to-right direction
</div>
<div class="dir-rtl end">
  End alignment in right-to-left direction
</div>
<div class="dir-ltr right">
  Right alignment in left-to-right direction
</div>
<div class="dir-rtl right">
  Right alignment in right-to-left direction
</div>
like image 181
Andreas Wong Avatar answered Oct 21 '22 08:10

Andreas Wong


Yes there is, according to css-tricks:

There are two new values in CSS3 as well, start and end. These values make multiple language support easier For example, English is a left-to-right (ltr) language and Arabic is a right-to-left (rtl) language. Using "right" and "left" for values is too rigid and doesn't adapt as the direction changes. These new values do adapt:

1: start - Same as "left" in ltr, same as "right" in rtl.

2: end - Same as "right" in ltr, same as "left" in rtl.

See detail here: text-align in CSS

like image 3
Saqib Amin Avatar answered Oct 21 '22 08:10

Saqib Amin