user5005297
user5005297

Reputation:

How to align something on both sides of an HTML page?

This may seem like a stupid question, but I need help. What would I write if I wanted to align some text to the left of the screen, and some on the right of the screen, both on the same line?

Upvotes: 0

Views: 1354

Answers (2)

Lance
Lance

Reputation: 3932

There are a couple of ways. This is one. The borders are just so it's easier to see.

div {
	border: 1px solid red; }

span {
	border: 1px solid blue; }

.r {
	dislay: inline-block;
	float: right;
	text-align: right; }
<div>
	<span>I'm Left</span>
	<span class="r">I'm Right</span>
</div>

Upvotes: 1

Ajay Narain Mathur
Ajay Narain Mathur

Reputation: 5466

Use float:left and float:right property of css.

Refer this fiddle

HTML:

<span class="float-l">left</span>
<span class="float-r">right</span>

CSS:

.float-l{
    float : left
}
.float-r{
    float: right
}

Upvotes: 3

Related Questions