I have a paragraph which has two seperate forms in it. However, when the page is loaded, there is a line break where each form starts. I am using the following code:
<p style="font-size:14px;font-weight:700;color:grey;">' . $user_pic . ' <a href="profile.php?id=' . $mem_id . '" style="color:#0F39C5;">' . $knockfirst . ' ' . $knocklast . '</a> is knocking. Let him in?
<form action="messages/group/addToChat.php" method="post" name="adduser"><input type="hidden" id="newid" name="newid" value="' . $mem_id . '"><input type="hidden" id="groupid" name="groupid" value="' . $group_id . '"><a href="#" onclick="$(this).closest(\'form\').submit(); return false;" style="color:#0F39C5;font-size:15px;">Yes</a></form>
<form action="messages/group/declineKnock.php" method="post" name="declineuser"><input type="hidden" id="newid" name="newid" value="' . $mem_id . '"><input type="hidden" id="groupid" name="groupid" value="' . $group_id . '"> |
<a href="#" onclick="$(this).closest(\'form\').submit(); return false;" style="color:#0F39C5;font-size:15px;">No</a></form></p>
Is there any way to keep this all on the same line when it's rendered onto the page?
To get all elements to appear on one line the easiest way is to: Set white-space property to nowrap on a parent element; Have display: inline-block set on all child elements.
In HTML, a tag is anything between < and > , so in your first example you had 2 form tags and 2 input tags. Attributes are the extra pieces of information in those tags, in the form key="value" , so in your first form tag you had the attributes action and method .
Add this to your css:
form {
display: inline-block; //Or display: inline;
}
Fiddle: http://jsfiddle.net/trW82/
add float
style to the first form -
style="float: left;"
better yet, create a separate CSS class -
.chatForm {
float: left;
}
and assign this class to the first form -
<form class="chatForm" ......
You can also set display
property of both form to either inline
or inline-block
-
.chatForm, .declineForm {
display: inline-block; /* or inline */
}
and then -
<form class="chatForm" .....
<form class="declineForm" ....
Demo.
Check out the sitepoint reference on display and float.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With