Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between direction and text-align in css

Tags:

html

css

What are the differences between:

  • direction : rtl

  • text-align: right

(Related to this question)

like image 775
gdoron is supporting Monica Avatar asked Dec 08 '11 11:12

gdoron is supporting Monica


People also ask

What is the difference between text-align and vertical align?

Answer: Text-align is used to align the text in center/left/right/justify horizontally and vertical-align aligns the element in vertically. ... The proper values for text-align are left|right|center|justify as it is horizontal, while the valign is vertical so it's top|middle|bottom|baseline.

What is the difference between float and text-align?

float moves the element itself, text-align moves the text inside the element.

What is direction in CSS?

The direction CSS property sets the direction of text, table columns, and horizontal overflow. Use rtl for languages written from right to left (like Hebrew or Arabic), and ltr for those written from left to right (like English and most other languages).

What are the four types of alignment in HTML?

There are four main alignments: left, right, center, and justified.


2 Answers

Direction orders your element from right to left.

Example:

<div style="direction: rtl">
  <div style="display: inline-block">A</div>
  <div style="display: inline-block">B</div>
</div>

outputs: B A

Text-align display your element in the right.

Example:

<div style="text-align: right; width: 979px">
  test
</div>

outputs test on the rightmost edge of the specified width.

like image 184
Neigyl R. Noval Avatar answered Oct 03 '22 08:10

Neigyl R. Noval


It’s easier to say what they have in common: the settings direction: ltr and direction: rtl imply the defaults text-align: left and text-align: right, respectively.

The other, more fundamental effects of the direction property are:

  • Text direction for directionally neutral text (as defined by Unicode directionality concepts; e.g. letters have inherent neutrality that is not affected by direction property, unless overridden using the unicode-bidi property).
  • Layout direction of blocks that appear side by side.
  • Layout direction of columns in a table.
  • Direction of horizontal overflow.
  • Alignment direction for the last line of text when text-align: justify is in affect.
  • Placement of list markers (list bullets or list item numbers) with respect to list items.

For example, if you wish to play with direction: rtl on an UL element to put list bullets on the right, for normal English you should set direction: ltr on the LI elements, to avoid messing up the text direction (when the text contains e.g. punctuation marks).

like image 30
Jukka K. Korpela Avatar answered Oct 03 '22 09:10

Jukka K. Korpela