If you can use JavaScript, the following might be the most portable option today (tested Firefox 31, Chrome 36):
contenteditable="true"
http://jsfiddle.net/cirosantilli/eaxgesoq/
<style>
div#editor {
white-space: pre;
word-wrap: normal;
overflow-x: scroll;
}
<style>
<div contenteditable="true"></div>
There seems to be no standard, portable CSS solution:
wrap
attribute is not standard
white-space: pre;
does not work for Firefox 31 for textarea
. Fiddle, open feature request.
Also, if you can use Javascript, you might as well use the ACE editor:
http://jsfiddle.net/cirosantilli/bL9vr8o8/
<script src="http://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js"></script>
<div id="editor">content</div>
<script>
var editor = ace.edit('editor')
editor.renderer.setShowGutter(false)
</script>
Probably works with ACE because it does not use a textarea
either which is underspecified / incoherently implemented, but not sure if it is uses contenteditable
.