Ali Ali - 1 year ago 37
HTML Question

how to show each two <p> in one line inside a div

i have a loop inside a jsp page , for each element of my arrayList i print a pragraph, this my code :

<% for(object ob:myList){ %>
<p> <%=ob.getName()%></p>

this code show me a lot of paragraphs, but each paragraph in one row, my issue is : how to show each two paragraphs in one line

thanks in advance.

Answer Source

In order to have two paragraph tags in 1 line you need some css:

p { 
    display: inline-block;
    width: 50%;


p { 
    float: left;
    width: 50%;

The 50% width is for 2 <p>'s to be on the same row and take half of the width.

Hope that helps.




Second update

Or use table-row and table-cell, which is the best-solution in my opinion and it is for multiple p tags.