Show div in one line

How to show div in one line with CSS? You know  div is a block element which is shown on a separated line by default. Only inline elements such as span or a are shown in single line. But that does not mean there is no way to show div elements in one line. On the contrary, there are quite a few methods to show divs on a line using css.

  • Use css property “display:inline;”
  • Use “display:inline-block;”
  • Use “display:inline-table;” for the parent div and “display:table-cell” for the contained children divs which are shown on one line.

All these methods can show two div in one line. The difference between “display:inline” and “display:inline-block” is explained in this article. The following is an example to show 2 div in one line:

<div style="display:inline-table;"><div style="display:table-cell;">div1</div><div style="display:table-cell;">div2</div></div>

 

 

Did you like this?
Tip admin with Cryptocurrency

Donate Bitcoin to admin

Scan to Donate Bitcoin to admin
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to admin

Scan to Donate Bitcoin Cash to admin
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to admin

Scan to Donate Ethereum to admin
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to admin

Scan to Donate Litecoin to admin
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to admin

Scan to Donate Monero to admin
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to admin

Scan to Donate ZCash to admin
Scan the QR code or copy the address below into your wallet to send some ZCash:

Leave a Reply