I have a long string (a DNA sequence). It does not contain any whitespace character. e.g.:
ACTGATCGAGCTGAAGCGCAGTGCGATGCTTCGATGATGCTGACGATGCTACGATGCGAGCATCTACGATCAGTCGATGTAGCTAGTAGCATGTAGTGA
what would be the css selector to force this text to be wrapped in an html:textarea or in a xul:textbox
I don't think you can do this with CSS. Instead, at regular 'word lengths' along the string, insert an HTML soft-hyphen:
This will display a hyphen at the end of the line, where it wraps, which may or may not be what you want.
Note Safari seems to wrap the long string in a
<textarea>
anyway, unlike Firefox.My way to go (when there is no appropiate way to insert special chars) via CSS:
As found here: http://kenneth.io/blog/2012/03/04/word-wrapping-hypernation-using-css/ with some additional research to be found there.
for block elements:
for inline elements:
Use a CSS method to force wrap a string that has no white-spaces. Three methods:
1) Use the CSS white-space property. To cover browser inconsistencies, you have to declare it several ways. So just put your looooong string into some block level element (e.g., div, pre, p) and give that element the following css:
2) use the force-wrap mixin from Compass.
3) I was just looking into this as well and I think might also work (but I need to test browser support more completely):
Reference: wrapping content
For me this works,
You can also use a div inside another div instead of
td
. I usedoverflow:auto
, as it shows all the text both in my Opera and IE browsers.If you're using PHP then the wordwrap function works well for this: http://php.net/manual/en/function.wordwrap.php
The CSS solution
word-wrap: break-word;
does not seem to be consistent across all browsers.Other server-side languages have similar functions - or can be hand built.
Here's how the the PHP wordwrap function works:
This wraps the string at 50 characters with a <br> tag. The 'true' parameter forces the string to be cut.