Home > Software design >  How do I stop the newline that a button makes in html?
How do I stop the newline that a button makes in html?

Time:11-16

So I have made a website, and I have a h1 but, i want to add buttons to the right of the h1 but when I add the button it creates in below the h1, I just cant figure out how to stop the newline.

I looked all over the internet but no one had this problem, i tried to switch to but it gave the same problem...

CodePudding user response:

headers are block elements by default, so they're displayed in separate blocks unlike inline elements you can overwrite this default behavior by specifying h1 as an inline-block

h1 {
  display: inline-block;
}
<h1>Some Header</h1>
<button>Button</button>

CodePudding user response:

There are two display values in HTML: block and inline. Every HTML element has a default display value.

Headings - are block level elements. So, they always start on a new line by default.

So, you could do something like this to solve the problem:

<h1 style="display:inline">heading</h1>
<button type="submit">Click</button>
  • Related