Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I show lines in a textarea to make it look like notepad?

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.

enter image description here

like image 431
Anshul Avatar asked Feb 15 '12 08:02

Anshul


People also ask

How do you highlight text in textarea?

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.

Which character defines new line in textarea?

Talking specifically about textareas in web forms, for all textareas, on all platforms, \r\n will work.

How do I insert a new line in HTML textarea?

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!


2 Answers

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.

like image 64
Simon Avatar answered Sep 18 '22 16:09

Simon


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

like image 24
epoch Avatar answered Sep 17 '22 16:09

epoch