Consider the following: (Live Demo)
HTML:
<div contenteditable></div>
CSS:
div {
text-align: right;
}
When you click the div
in Firefox, the cursor is located at the left (looks like text-align: right;
has no effect). But, if you start typing, text-align: right;
starts taking effect.
Why is that? Any ideas how to fix this?
The text-align property in CSS is used for aligning the inner content of a block element. These are the traditional values for text-align: left – The default value. Content aligns along the left side.
Note. The text-align property only aligns the inline content (ie: text) of an element within its parent block element. The text-align property does not align a block element itself, only the inline content.
Align the text left or right Select the text that you want to align. On the Home tab, in the Paragraph group, click Align Left or Align Right .
The left value of the text-align property is the default. So, every content inside a block-level element is aligned to the left by default.
This can be achieved using a simple change like this:
<div contenteditable> </div>
We're forcing a blank space in it.
Well if the space matters, I think you have a problem. But I hope this helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With