By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,948 Members | 1,929 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,948 IT Pros & Developers. It's quick & easy.

Align left and right on a single line

P: n/a

How can I have some text aligned to the left of the page and some more
text aligned to the right using only CSS without a table?

SPAN doesn't have any alignment, and there is only a single DIV block
per line, and so only one alignment.

TIA

Craig
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Craig Thomson wrote:
How can I have some text aligned to the left of the page and some more
text aligned to the right using only CSS without a table?

SPAN doesn't have any alignment, and there is only a single DIV block
per line, and so only one alignment.


The following is a crude example of what can be done. But it obviously won't
work right at narrow viewport widths, because the bits of text overlap. You
need to work out what you want to happen under various circumstances, because
that will tell you which of many options to use.

HTML:

<div class="line">
<span class="left">Left hand text</span><span class="centre"> Centre text
</span><span class="right">Right hand text </span>
</div>

CSS:

span.left {
position: absolute;
left: 0;
}
span.right {
position: absolute;
right: 0;
}
div.line {
position: relative;
text-align: center;
width: 100%;
}

--
Barry Pearson
http://www.Barry.Pearson.name/photography/
http://www.BirdsAndAnimals.info/
http://www.ChildSupportAnalysis.co.uk/
Jul 20 '05 #2

P: n/a
Craig Thomson wrote:
How can I have some text aligned to the left of the page and some more
text aligned to the right using only CSS without a table?

SPAN doesn't have any alignment, and there is only a single DIV block
per line, and so only one alignment.


The following is a crude example of what can be done. But it obviously won't
work right at narrow viewport widths, because the bits of text overlap. You
need to work out what you want to happen under various circumstances, because
that will tell you which of many options to use.

HTML:

<div class="line">
<span class="left">Left hand text</span><span class="centre"> Centre text
</span><span class="right">Right hand text </span>
</div>

CSS:

span.left {
position: absolute;
left: 0;
}
span.right {
position: absolute;
right: 0;
}
div.line {
position: relative;
text-align: center;
width: 100%;
}

--
Barry Pearson
http://www.Barry.Pearson.name/photography/
http://www.BirdsAndAnimals.info/
http://www.ChildSupportAnalysis.co.uk/
Jul 20 '05 #3

P: n/a
Craig Thomson <cr***@spam.free> wrote:
How can I have some text aligned to the left of the page and some more
text aligned to the right using only CSS without a table?


By using a css table and a hack to supply poor old IE with a float
replacement.

--
Spartanicus
Jul 20 '05 #4

P: n/a
Craig Thomson <cr***@spam.free> wrote:
How can I have some text aligned to the left of the page and some more
text aligned to the right using only CSS without a table?


By using a css table and a hack to supply poor old IE with a float
replacement.

--
Spartanicus
Jul 20 '05 #5

P: n/a
Spartanicus <me@privacy.net> wrote:
How can I have some text aligned to the left of the page and some more
text aligned to the right using only CSS without a table?


By using a css table and a hack to supply poor old IE with a float
replacement.


Example:
http://www.spartanicus.utvinternet.i..._using_css.htm

--
Spartanicus
Jul 20 '05 #6

P: n/a
Spartanicus <me@privacy.net> wrote:
How can I have some text aligned to the left of the page and some more
text aligned to the right using only CSS without a table?


By using a css table and a hack to supply poor old IE with a float
replacement.


Example:
http://www.spartanicus.utvinternet.i..._using_css.htm

--
Spartanicus
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.