tags:

views:

298

answers:

2

I need to put a Confirm button and a cancel button in a page.

I chose to create to forms with different actions, but the 2 buttons (forms) are not displayed side-to-side.

How do we do it without a table?

Thank you!

+1  A: 

Make both "float: left". And make the element after them "clear: both";

Should work :)

Dmitri Farkov
+3  A: 

You can do this without floats, if you set the form and every element inside it to be display inline then they will sit next to each other. The reason they are not side by side is because forms, just like divs and paragraphs are block level elements, setting them to be display inline will fix this.

For Example

.button-container form,
.button-container form div {
    display: inline;
}

.button-container button {
    display: inline;
    vertical-align: middle;
}

With the following HTML

<div class="button-container">
    <form action="confirm.php" method="post">
     <div>
      <button type="submit">Confirm</button>
     </div>
    </form>

    <form action="cancel.php" method="post">
     <div>
      <button type="submit">Cancel</button>
     </div>
    </form>
</div>
Natalie Downe
Using the HTML button element is a bad idea, because different browsers treat its submit values differently. Use the input element for buttons in forms.
Sam DeFabbia-Kane
Natalie, Sam DeFabiia-Kane might be right, but your help was very valuable! Thank you!
Sam - actually, 'button' is much more versatile when designing. Just add the type explicitly, don't rely on a browser's defaults, e.g. <button type="submit>..</button>
orip
+1 - if you want inline elements, make them inline (meaning they don't take a full row). There are issues when using floats, better not to use them when you don't need them floating.
orip