Hamster
Hamster

Reputation: 3122

How do I top-right position an element next to a paragraph?

Let's say my setup is like this:

<div style="width:200px;">
    <label for="derp">This is an arbitrary paragraph of text that happens to be a label for a form element, in my case.</label>
    <input type="checkbox" name="derp">
</div>

Applying float: right; to the checkbox positions it to the right, but I need it to push up through the text label to the top right of the container.

I seem to be losing grasp of simple concepts...

Upvotes: 1

Views: 40

Answers (1)

crimson_penguin
crimson_penguin

Reputation: 2778

When you float an element, it floats next to content that comes after it, not before. So switch the order of the label and input and it should work.

Upvotes: 1

Related Questions