Ask coding questions

← Back to all posts
Display elements of the same class next to each other horizontally
NSCarter (3)

I have four divs in my code. Two are members of the "top" class and two are members of the "bottom" class. I want the divs in the top class to be displayed next to each other and above the divs in the bottom class but at the moment they all display one below the other. The number of divs could change but there will always be an equal number in the top and bottom class.

EthanJustice (63)

As Edgod said, change the display property for the divs from table to inline-block. Further reading: W3 and MDN.

Edgod (78)

Change the css display property to
display: inline-block;

NSCarter (3)

@Edgod That displays them all on the same line. I need the two classes on separate lines.