How to align two boxes in a line?

Two differnet javascript codes to output to one line?

  • I wish to run two different javascript codes - one for the time and a greeting (right align) and the other for a facebook like button. I have entered both of the codes but it displays the second code on a new line. How do I tell it not to but the second code on a new line? Here is the code: ((Here is the facebook like button code - This line is not in the code)) <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfb… fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="http://www.facebook.com/pages… data-send="false" data-layout="button_count" data-width="450" data-show-faces="false" data-font="tahoma"></div> ((Below is the time/greeting code - This line is not in the code)) <script type="text/javascript"> var d = new Date() var time = d.getHours() var currentTime = new Date() var hours = currentTime.getHours() var minutes = currentTime.getMinutes() var suffix = "AM"; if (hours >= 12) { suffix = "PM"; hours = hours - 12; } if (hours == 0) { hours = 12; } if (minutes < 10) minutes = "0" + minutes if (time<12) { document.write("<p align=right>Good Morning " + hours + ":" + minutes + " " + suffix + "</p align=right>"); } else if (time>=12 && time<18) { document.write("<p align=right>Good Afternoon " + hours + ":" + minutes + " " + suffix + "</p align=right>"); } else { document.write("<p align=right>Good Evening " + hours + ":" + minutes + " " + suffix + "</p align=right>"); } </script> The webpage can be seen here: http://www.tractorrepairparts.com

  • Answer:

    You are enclosing the date and time in a <p> tag. It is the default nature of a <p> tag to place itself on a new line. you can instead use <span> tag which will not put you date and time on a new line. And FYI there's an error in your code - "</p align="right">" is wrong syntax . ending tags never have attributes. you simply have to write "</p>". Hope i helped!

Better By D at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.