Before and after with "img" and "p"...???

Before and after with "img" and "p"...???

Hello!
If I write text before and after "img" it appears in the same line, but if I use "p" instead, I get p text, befoe text and after text in 3 lines.

How can I achiev to have before text and after text in the same line as p text?

Many thanks!!!

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  5. <script>
  6. $(document).ready(function(){
  7.   $("#btn1").click(function(){
  8.     $("p").before("<b>Before</b>");
  9.   });

  10.   $("#btn2").click(function(){
  11.     $("p").after("<i>After</i>");
  12.   });
  13. });
  14. </script>
  15. </head>

  16. <body>
  17. <p> Element p</p>
  18. <br><br>
  19. <button id="btn1">Insert before</button>
  20. <button id="btn2">Insert after</button>
  21. </body>
  22. </html>