how to word wrap in normal html textbox? - html

i have this text box
<p>Event Data :<input id="data" type="text" wrap="true" value="{{data}}"
style="width: 757px; height: 170px" />
</p>
i want it to be multiline
i can't use asp:textbox
is it possible to use exact textbox and make it multiline or
make the text in textbox go word wrap

How about this:
<p>Event Data:
<textarea id="data" style="width: 757px; height: 170px" rows="10" cols="80">{{data}}</textarea>
</p>
Hat tip (and +1) to Stewart for pointing out that rows and cols are required attributes to textarea.

<p>Event Data:
<textarea id="data" rows="10" cols="80">{{data}}</textarea>
</p>
rows and cols are required attributes. Don't ask me why. And if you're going to set the size in CSS, it's generally better to do it in em or % rather than px.

If you mean that you want your text values to display as multi-lines, use add a white-space: pre; style to the textarea element, making sure to put put the proper line-breaks into the returned {{data}}

You will need to use a <textarea> with a wrap attribute. It is not in any HTML standard but to my knowledge the settings "soft", "hard" and "off" work in all major browsers. Definitely in IE. Firefox seems to require a "cols" setting for wrap to work, though.

Related

Why does <textarea> in React accept a value attribute but in HTML, it does not?

Not sure if this is React specific, but, why does the following work in React and render some text to the element:
<textarea value="Some text."></textarea>
but the same in plain HTML does not:
<textarea value="Some text."></textarea>
maybe I am missing something or done something foolish? Apologies and thanks in advance!
In HTML the text area is a non-self-closing tag and has content. It defines its text by children.
textarea
<textarea id="story" name="story" rows="5" cols="33">
It was a dark and stormy night...
</textarea>
In React it uses the value attribute. Note that is also self-closing and takes no children.
textarea tag
This keeps the textarea element consistent with other form elements such as input and select.
<textarea
id="story"
name="story"
rows="5"
cols="33"
value="It was a dark and stormy night..."
/>
The textarea child content represents the default value of a text area, but the value property represents the current value.
It is the current value that needs to be manipulated via JS, not the default value.

In html textarea tag automatic takes 4 spaces

When click middle position of the HTML textarea tag , it automatic takes 4 space. I want,dont take any space in textarea.
<textarea rows="2" cols="40" name="chief_complaints" class="form-control" value="">
</textarea>
How to solve this problem?
According to the standard, the textarea element does not support the value attribute, instead of that everything between <textarea> and </textarea> belongs to the value of the text area. To get rid of any spaces and newlines you have to write <textarea></textarea> without anything between the start and the end tag.
<textarea>[DON NOT USE BREAK LINES AND SPACES HERE, LET IT BE BLANK]</textarea>
For example:
<textarea rows="2" cols="10">Your Content</textarea>

how do i align textarea field in line with the width of textbox fields in an html form?

i was designing a webpage form which has couple of textboxes and textarea fields in it, and noticed that certain alignment issues with these fields.
The code is as below -
<textarea rows="4" cols="30" name="details"></textarea>
<input type="text" name="username" size="30"></input>
Although both fields have col width set to 30, i see that the textarea width extends over the width of the textbox. I used overflow:hidden using css for the textarea field, and then tried resizing it using the cols property set to 25, 26 etc.., but still see that the alignment is not perfect (though very close).
Question - Is there a better way to align all the fields in the form to have a standard width of say 30cols?
Using CSS to style the elements is the usual way:
<textarea style="width:400px;" rows="4" cols="30" name="details"></textarea><br/>
<input style="width:400px;" type="text" name="username" size="30"/>
I'm using inline styles as example only, you'd want to assign classes, use a stylesheet, etc. Plus I fixed the typo on the text input element as it is a self closing tag.
Good luck!
Try adding this to your css stylesheet:
textarea#styled {
width: 600px;
}
Then add the id to your textarea:
<textarea rows="4" id="styled" name="details"></textarea>
You could also try putting both of these elements inside of an html table with the table's alignment set to middle.

HTML input wrap text instead of overflow horizontally

I have an input field, in which a user will enter text inside. When the text becomes too long, the input field extends horizontally instead of dropping down vertically.
I tried adding this CSS:
overflow: hidden;
word-wrap: break-word;
but I had no luck. Any other suggestions on how to accomplish this?
I think you should use a multiline input field as TextArea:
http://htmlhelp.com/reference/html40/forms/textarea.html
Sample code:
<textarea rows="10" cols="30"></textarea>
Xtian - You shouldn't have any restriction on where you need to use an <input> or a <textarea>. Just give the text area the same name that you would've used for the input and you'll be fine.
For example, I just replaced
<input type="text" name="reply" />
With
<textarea rows="1" cols="26" name="reply"></textarea>
Much better now.
This is a soultion i found, Just use a hidden input and use a button for the text with a action for the form.
<form method="post" action="nextpage.php">
<input style="display: none;" name="name" type="text" value=“somedata"></input>
<button>Some text that you want to wrap but also submit the form </button>
</form>

Textarea css not clickable

How to set the css of a textarea not to be clicked on it.
<textarea></textarea>
Thanks
Try
<textarea disabled="yes"></textarea>
In most browsers, this will grey out the content of the textarea though, and the user won't be able to copy any text from within it. If you don't like that, you can use:
<textarea readonly="yes"></textarea>
The textarea will then remain clickable, and the user will still be able to select/copy text within it, but he won't be able to edit it.
So you don't want the user to edit the contents of the textarea? Simple solution: Don't use textarea. Just use a normal div or pre and style it.
You Cant do this with CSS, you have to do it in the markup like so:
<textarea disabled="disabled"></textarea>
If you care to be By-The-Book & standard compliant it is as follows :
For "Unclickable"
<textarea readonly>
...
</textarea>
For "Grayed & unclickable" aka Disabled :
<textarea disabled>
...
</textarea>
You can find all other properties of "textarea" here.