Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap textarea adding space characters inside text field

I am using Bootstrap 3 RC1. The Problem I am having is with the textarea — when the page loads it adds 3 spaces to the texarea, ultimately making the placeholder text invisible, unless I manually delete the spaces.

How do I stop this from happening?

HTML

<form id="noteSubmitForm">
  <fieldset>
    <textarea id="note-text" rows="6" placeholder="Add a note" class="form-control">
    </textarea>
    <div class="form group">
      <button id="noteSubmitButton" type="submit" class="btn btn-success btn-custom">
        Save Note
      </button>
    </div>
  </fieldset>
</form>

CSS

textarea#note-text {
  width: 625px !important;
}
like image 751
Evan Emolo Avatar asked Aug 07 '13 14:08

Evan Emolo


1 Answers

How do I stop this from happening?

By not having whitespace between your textarea tags, as you have right now:

    <textarea id="note-text" rows="6" placeholder="Add a note" …>
    </textarea>

There’s a line break (first line break directly at the beginning gets ignored by browsers though), and then there are spaces before the closing tag, so those are part of the value content of your textarea as well, because that’s how the content of a textarea is written – between the opening and closing tag.

If you don’t want content there – don’t put content there:

<textarea …></textarea>
like image 93
CBroe Avatar answered Oct 15 '22 17:10

CBroe