There are times when you want to insert plain text into your Blog Post or template. This may be a piece of HTML code or JavaScript that you would like readers to copy, such as the “Link to Our Site” code in the sidebar. It could also be the Terms of a Legal Agreement that users can view. As we shall be discussing in our article on creating forms in Blogs, the text box can also be used in feedback forms for users to input feedback and comments.
The HTML code of the text box makes use of the <textarea> property. For the text box to be in a Blog Post, while drafting the Post, switch to “Edit HTML” mode to insert the following code. If it is to appear in the sidebar or other parts of the template, go to Template -> Page Elements -> Add a Page Element and select “HTML/JavaScript” to insert this code.
Users can input text
The textarea HTML code which allows users to input TEXT is this:-
<textarea rows="5" cols="40"> TEXT </textarea> |
|---|
The attribute cols indicates the number of visible columns and the rows shows the number of visible rows. Note that this simply sets the dimensions of the text box. The lines of text can exceed the specified area, and when that happens, there will be scrollbars at the sides to allow users to view all the contents. In the above code, users can input words and characters into the text area. There is no limit to the amount of text that can be inserted but browsers may have their own preset limits. This is what readers will see:-
Read only Textbox
If the text box contains terms and conditions or information, we can insert a <readonly> attribute into the textarea code. Readers can view the text but they cannot edit or amend it, or insert any input into the box. This is the HTML code:-
<textarea rows="2" cols="30" name="Famous Quotes" readonly="readonly"> “Asking a working writer what he thinks about critics is like asking a lamp-post how it feels about dogs.” ... Christopher Hampton </textarea> |
|---|
We changed the value of the rows and cols to give you an idea how big the boxes will be with these values. A name can be assigned to the textbox for scripting purposes. Here, we have set it to display a readonly text which users cannot edit, but can still select and copy, like this:-
Link to Site Text Box
To display a code for readers to link to your Blog, you can make use of the <readonly> attribute. Instead of text, insert the Hyperlink HTML code. The textarea code can be this:-
<textarea rows="4" cols="25" name="Link to Site" readonly="readonly">Hyperlink Code</textarea> |
|---|
Textarea Word Wrap
This is perhaps more relevant when we apply the textarea code to forms. When the text reaches the end of a row, the words can be wrapped in these manners:-
"soft" wrap – text will wrap as the user types but line breaks are not included when the text is submitted in a form.
"hard" wrap – if users enter line breaks into the text, it will be shown in the submitted form.
wrap is "off" – this will put all the words in one line, without any line breaks or wrapping.
The default value is "soft" wrap.
<textarea rows="8" cols="30" wrap="hard"> TEXT </textarea> |
|---|
© Tricks for New Bloggers


12 comments:
Hi there.
I have problems while working on this code. Everytime I type "enter", the text box always show '<' br/ '>'
How can I get rid of those unwanted codes, but still can have multi lines text in the text box?
Huge thanks.
suryaholic@gmail.com
hi , thank u very much for this great topics
but i have a problem
when i break line 9 press enter 0 in the textarea box , it shows me word (brb) which means a new line
and when i type in colored , it show me (span)
and i cant delet it
can u help me or give me ur code by which u can type html colored codes that i see in your blog ?
thank u agian
hi
I have set up a search box with text typed in the box serving as a sample. I kind of expected those sample letters would automatically disappear as soon as I start typing in the box..... tried using the"OnClick" and "Reset", but didn't work...Could you please help me out with this?
Thanks a lot,
Angie
I tried this and it worked but it looked ugly. The background was white in a green post page.
How do I add HTML code to display for readers like you have done in your blog so that they can copy and paste? Yours is so neat and tidy.
Thank you! (I have checked off the email follow-up.)
Please help me to show my css code inside the scroll box code that you show here. The css code is changing or it is automatically encoded. I want to show the css code as itself
Thanx
Thanks . the post was really helpful to me
Nithya
Thanx for the add text tip...
It really helps...
Pliz visits my blog at poisonedchocolate.blogspot.com
it's very great....
Now I've kept Ur page in My Book Mark list....and I read everytime, thank U very Much for ur Tips..
j-o-v-i-e
How do you add a colored box background around each post?
HELP!!! Ok. It's almost working. One slight problem -- I type it all in HTML and then when I click over to compose view, the text "http://not-a-real-namespace" has been mysteriously added in front of my a href address. ACK! What am I doing wrong???
Of course I've pushed this to a deadline. Any way you can help me before Friday??? ;^)
Hello!
Thanks a lot for such a nice articel
really gud
i was searching for it
thanks to owner
Dunno if it's relevant, but I found this site which has pretty much word-for-word of this posting. http://weblogian.com/blog/index.php/2008/07/add-text-box-and-textarea/
I know it's a pretty old post, but I just came across it and didn't see anything credited to your site (the date tags says yours came first).
Sorry if I am wrong and they are posting it with all the rights necessary, it's just that they seem to be claiming copyright over it (they copyright their site which implies that everything not credited to somewhere else is theirs).
-Crayboff (slightlytoastedtomatoes.blogspot.com)
P.S. I know this comment has to go through moderation, so don't publish it if you don't want to, I just couldn't figure out any other way to bring this to your attention (an email address would be nice)
I have something to say ...