I have an HTML textarea with a "placeholder" attribute that includes the code for a line break, &\#10;. It works fine on Chrome, but the line break is ignored on other browsers. What is causing this inconsistency, and how do I work around it?
Include the line break naturally with the keyboard enter? Like it is shown in this image, click to see it.
If it does not work, try inserting your place holder text via javascript?
See Insert line break inside placeholder attribute of a textarea?
Related
Looking for a CSS property which will run on all the browsers where condition for word is as follows.
1. word should not be break.
2. href link text should be break within the html tag.
3. hyphen text should not be break.
4. The content may be in DIV, span or in a tag having multi lines.
CSS has white-space property which can be used.
URL : https://www.w3schools.com/cssref/pr_text_white-space.asp
For all links, you can add the following code:
a{white-space:initial;}
I am trying to enable manual line breaks in <td> tag in HTML.
Content is coming from a file which consists of ENTER or manual line breaks, but while displaying this data in HTML table, data is being displayed continuously. Means it is ignoring manual line breaks.
Is there any way to make <td> tag to consider manual line breaks or ENTER you can say?
For example:
Text coming from DataBase:
Line 1.
Line 2.
Line 3.
(with ENTER after each line)
Data displayed in table cell:
Line 1.Line 2.Line 3.
(not considering ENTER after each line)
Tried different ways but failed. Please suggest some solution.
Please try this
str = str.replace(/(?:\r\n|\r|\n)/g, '<br />');
this will covert all enter key pressed to line break
OR
You can use 'pre' tag.
Reference
The best solution is to put your text inside a span tag with white-space: pre-wrap style, and even more if you are working with Bootstrap (where pre tag is styled).
CSS white-space Property (relevant) options:
pre: Whitespace is preserved by the browser. Text will only wrap on line breaks. Acts like the tag in HTML.
pre-line: Sequences of whitespace will collapse into a single whitespace. Text will wrap when necessary, and on line breaks.
pre-wrap: Whitespace is preserved by the browser. Text will wrap when necessary, and on line breaks.
When i add plain text inside pre tag it's formatted( space changed to line-break to <br /> and so on). When i add it in html view - all spaces and line-breaks are deleting too. It seems to me unnecessary.
How can i stop TinyMCE doing this, save original formatting inside <pre> block?
It is formatted depending on your browser. You won't be able to change that- and if you are you shouldn't do it.
In Firefox the br-element is necessary to be able to click inside the html element, so is the .
Spaces added in html view at the end or beginning of a html-element get removed (trimmed out) by default - that is correct btw.
Yes, so I got the problem that if you type a long sentence with no space e.g eeeeeeeeeeeeeeeeeeeeeeee, it will break itself, but then now I would need to start typing some ugly non-breaking coding.
Example:
http://jsfiddle.net/r3CFJ/
I need to have everything in one sentence in order not to make it break itself. Check here to see the result of not having everything in one sentence:
http://jsfiddle.net/r3CFJ/1/
How can I fix this please any solutions?? as my further coding will get very ugly and not readable?
You are getting this spacing because of the CSS, I am not sure why you add the pre type formatting and then wonder why it shows 'exactly' what you do (multiple lines, etc).
If you remove the CSS it looks just fine on 1 line.
Look: http://jsfiddle.net/r3CFJ/10/
Here's the problem, the white-space property in CSS forces new lines to break for all values except "normal" and "nobreak". There is no value for this property that will allow you to wrap lines while no breaking on new lines in the code. Don't like it? Get the W3C to add another value and get the major browsers to adopt the rule.
You don't want your entire div to be subject to a property set to such a value since you don't want new lines to break within the div. You do want elements inside your div to be subject to such a property. Wrap all the text in anchor element tags and apply the CSS to the elements that will require wrapping.
Here's a modification of your example working as expected. (Assuming no forced breaking due to line breaks in code but wrapping of long lines)
If you want the image and text will be inline set a or fancybox_vid to be position:absolute;
Example http://jsfiddle.net/huhu/r3CFJ/30/
I have a textarea. When I paste text with line breaks into it, the line breaks are automatically removed. But when I manually enter line breaks (hitting carraige return), they are preserved.
How do I force the textarea to preserve line breaks with pasted text?
Don't know if this applies to all browsers, but in Google Chrome (6 and 7), line breaks in pasted text gets removed if the textarea's style is set to white-space: nowrap;.
I used this style setting to prevent the default wrapping of long lines and experienced the same problem as yours. Later I realized that setting the textarea attribute wrap to off does a much better job. Be aware that wrap="off" is widely supported but not standardized.
The line breaks are always preserved when pasted on textarea.
Maybe the source have a different line break, you are copying from what program?