1

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.

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.