Akshay Seth
Akshay Seth

Reputation: 13

Why the input tag is going in next line?I want it in the same line

<p>Name:</p><input type="text" style="display: inline" >

The input tag is going in the next line.I want it to be in the same line.I used the css styling property too but it isn't helping.

Upvotes: 1

Views: 38

Answers (2)

Igor Unger
Igor Unger

Reputation: 182

As @David explained the <p> tag is a block element. That means in won't align inline on default.

To solve your problem change your markup to:

<p>Name: <input [...] /></p>

But for what you are trying to do there is the label-tag.

<label for="name">Name: </label><input type="text" name="name" />

Upvotes: 0

David
David

Reputation: 218930

Because the p element is a block element. If you want anything to be inline with it, then it too would need to be inline:

<p style="display:inline">Name:</p><input type="text" />

Upvotes: 1

Related Questions