Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make two <div>...</div> in the same row?

Tags:

html

I mean, the two tags have the same height.

like image 500
Keating Avatar asked Dec 02 '10 23:12

Keating


People also ask

How do I put two divs in the same row?

The two or more different div of same height can be put side-by-side using CSS. Use CSS property to set the height and width of div and use display property to place div in side-by-side format. The used display property are listed below: display:table; This property is used for elements (div) which behaves like table.

How do I put div next to div?

With CSS properties, you can easily put two <div> next to each other in HTML. Use the CSS property float to achieve this. With that, add height:100px and set margin.

How do I make HTML elements on the same line?

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.


2 Answers

Try this for all divs.

display:inline-block;
like image 126
Ives.me Avatar answered Sep 24 '22 02:09

Ives.me


Simple: use <span>s instead.

<div> by default have display: block, meaning the next element will be on a new line.

You can change them to display: inline to get the behavior you want. But remember that an inline <div> is just a <span>.

like image 30
Yuval Adam Avatar answered Sep 22 '22 02:09

Yuval Adam