0

I have a form that looks like this:

    <form class="navbar-form text-center">
        <input type="text" class="span2">
        <p></p>
        <input type="text" class="span2">
        <p></p>
        ...
        <button type="submit" class="btn btn-success">I'm Done</button>
    </form>

Right now I'm using the <p></p> block, but that seems far from elegant to me.

I'd like to know if there was a better way because I searched a bit and couldn't find one. Thanks!

EDIT: I'd like to avoid additional HTML if possible like br and p tags.

4 Answers4

2

Very simple answer: use a breaking space.

For example:

a
<br>
b

Will render like this:

a
b

If you want a space between your elements, just add another <br>, like so:

a
<br>
<br>
b

Which will render like this:

a

b
Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
1

See http://twitter.github.io/bootstrap/base-css.html#forms

<div class="controls controls-row">
  <input type="text" >
</div>
Tom Carchrae
  • 6,398
  • 2
  • 37
  • 36
  • This would be excellent for larger forms, but I think that I'll be working with a dozen elements at max so it feels like overkill. Thanks for the link and I will keep this in mind. –  Apr 30 '13 at 05:33
  • this is the recommended way of breaking up bootstrap forms! :) you're generally not supposed to use any kind of 'fudge' HTML code with bootstrap. – Tom Carchrae Apr 30 '13 at 14:47
1

As a pure CSS solution, you could use:

input.span2 {
    display: block;
    margin-bottom: 10px;
}
Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
1

You are correct in thinking that you shouldn't add additional HTML purely for presentation that adds no semantic value. CSS Is on your side.

.span2 {
    display: block;
    margin-bottom: 25px;
}

http://jsfiddle.net/AGp2g/

Explosion Pills
  • 188,624
  • 52
  • 326
  • 405