Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I place two headings next to each other using CSS?

<h5>Category</h5><h6>auto</h6>

places Category and auto on separate lines, like this:

Category

auto

How can I place them both on the same line, like this?

Category auto

like image 989
w35t Avatar asked Aug 18 '09 14:08

w35t


1 Answers

h(n) elements are 'block' elements, which means they will grow to take all available horizontal space. This also means they will push anything "right" of them down to the next line.

One easy way to accomplish this is to set their display to inline:

<style>
    h5, h6 {display:inline;}
</style>

Note that inline-block is not supported in all browsers.

You can also float block elements, but that can become a sticky issue as floating can be fairly complex. Stick with inline for cases like this.

like image 164
Rex M Avatar answered Nov 02 '22 03:11

Rex M