I need to show lines in my text-area to make it look a like notepad. I have a single text-area only. The below notepad is for reference.
You can't actually highlight text in a <textarea> . Any markup you would add to do so would simply display as plain text within the <textarea> . The good news is, with some carefully crafted CSS and JavaScript, you can fake it.
Talking specifically about textareas in web forms, for all textareas, on all platforms, \r\n will work.
To add line breaks to a textarea, use the addition (+) operator and add the \r\n string at the place where you want to add a line break, e.g. 'line one' + '\r\n' + 'line two' . The combination of the \r and \n characters is used as a newline character. Here is the HTML for the examples in this article. Copied!
Here's an idea: http://www.bookofzeus.com/articles/css-styling-textarea-give-notebook-notepad-look/
In short: set a background-image
and set line-height
to whatever line height the image is using.
You can do this with CSS styling, based on your image, you can do this:
textarea#area {
width: 300px;
height: 400px;
padding: 0 0 0 20px;
line-height: 30px;
background: #fff url("http://i.stack.imgur.com/UfzKa.jpg") no-repeat -75px -160px
}
See the example fiddle here
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