Wrap attribute of textarea tag

4

What is the utility of the wrap attribute of the textarea tag?

What's the difference between your soft, hard, off values?

    
asked by anonymous 17.02.2016 / 17:23

2 answers

2

Just to complement the other response, as per the documentation for MDN

Indicates how text wrapping should work in <textarea>

  • hard : The browser automatically inserts line breaks (CR + LF) at the time the form is submitted so that each line does not exceed the field width limit, the attribute cols must be specific.

  • soft : (this is the default heat if omitted wrap="" ) The browser ensures that all line breaks in value consist of a pair (CR + LF) insert any additional line breaks when the form is submitted.

According to the w3.org are of the values ( soft and hard) are new HTML5 features, even if it works in some older browsers, it might not be standard .

  

Note:

     
  • Carriage return (CR, 0x0D, \ r) moves the cursor to the beginning of the line without advancing to the next line. This character is used as a newline character in the Commodore and Early Machintosh operating systems (OS-9 and older).
  •   
  • Line feed (LF, 0x0A, \ n) moves the cursor to the next line without returning to the beginning of the line. This character is used as a newline character on UNIX-based systems (Linux, Mac OSX, etc.)
  •   

Source: link

    
17.02.2016 / 20:41
3

The wrap attribute specifies how the text in the textarea element is to be adjusted when a form is submitted.

Soft : The text in the element is not adjusted when it is submitted in a form. This is the default value.

Hard : The text in the element is adjusted (containing new rows) when it is submitted in a form. When hard is used, the cols attribute must be specified.

EDIT

This makes it a great way to give users an example or description of how to proceed to fill in the text area field. Something like, "Please limit your answer to 100 characters," would be an ideal description.

References:

HTML wrap Attribute

Tizag - HTML - textareas

    
17.02.2016 / 17:51