Philipp Steinmann
Philipp Steinmann

Reputation: 11

Problem with <input> positioning in HTML/CSS

Hey guys, I'm a total HTML and CSS noob who was just coding his offline website when he ran across a problem.

I have a div in which I have positioned several elements using absolute positioning. But when I try to position an input field, it does not vertically lign up with the other text. Here's an example:

<div id="TopBar">
[...]
<h2 class="SubTitle" style="position:absolute; top:50px; left:75%;">Username: </h2>
<input type="text" name="username" style="display:inline; positon:absolute; top:50px; right: 5%;" />

When i run this code, the input field is about 30 pixels further up than the "Username:". Why is that, even though both have "top: 50px"?

Through testing, I have discovered that the code works properly without the div around it. Why is that?

I know my coding is really bad, please explain to me what I did wrong.

Upvotes: 1

Views: 10938

Answers (1)

Matthew Lehner
Matthew Lehner

Reputation: 4027

You have a spelling mistake in the tag. Fix "position" and it'll work for you!

Upvotes: 5

Related Questions