473,549 Members | 2,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Align left and right on a single line


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
6 100372
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">Le ft hand text</span><span class="centre"> Centre text
</span><span class="right">R ight 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
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">Le ft hand text</span><span class="centre"> Centre text
</span><span class="right">R ight 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
Craig Thomson <cr***@spam.fre e> 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
Craig Thomson <cr***@spam.fre e> 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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1707
by: Steve Leferve | last post by:
Hey folks - I have a table for reviewer comments. There is a field called 'txtComment' where it stores a one-sentence comment. In the report, we have these grouped and broken down by category id. Right now they are line items. I would like to have each comment run together, so that they appear as a paragraph, and not each field on a...
11
5097
by: Bruce A. Julseth | last post by:
I have: If (Microsoft.VisualBasic.Left(TextBox1.Text, 1) = "$") Then TextBox1.Text = Microsoft.VisualBasic.Right(TextBox1.Text, TextBox1.Text.Length - 1) End If Adding: Imports Microsoft.VisualBasic
6
2210
by: James Brown [MVP] | last post by:
Hi, I am having trouble understanding how the 'const' modifier affects the 'left-right' rule when deciphering c-declarations: const int *x; // x is a pointer to a 'const int' int const *x; // ?? these are the same, right? in this case the basetype is 'const int' ? int * const x = 0; // x is a const-pointer to int
3
7870
by: Sjef Janssen | last post by:
Is it possible to have a box (div) which sets a background-color and which contains (on the same line) text which is left aligned and text which is right aligned. (as in a table: two td's left one left aligned, right one right aligned). Thanxs!!
8
4604
by: Chaitanya | last post by:
Hello, In my Application i want to know when user clicks both the "Left" and "Right" buttons of the Mouse. I am getting a number like this "3145728". But the MouseButtons Enum contains only Left, Right, Middle, None, XButton1 and XButton2. I am using .NET 1.1 version. How can i convert "3145728" to MouseButtons Enum? why Mouse Left+Right...
6
2359
by: Michael7 | last post by:
Hi everyone, Me again! I'm having a problem centering a single line in a div. I have a news section that is a block of it's own, and centered. The text in the news section is left aligned of course, but I want the "Latest News" line at the top to be centered within that block. Mimicing the News Section at the bottom of my page here:...
14
2668
TheServant
by: TheServant | last post by:
Hi guys, I have done this before, but I can't figure out why it won't work. If any of you can see my problem, please let me know. Here are the relavent pieces of code. <!-- Main Content --> <div class="main_content"> <!-- Content --> <div class="content"> <p>main content</p> </div> <!-- End of Content -->
1
3300
by: vikastcser | last post by:
Hi All , I have a table where four rows are there and each row has two tds.one td is for label and two image icons and other td is used for keeping numeric values. I am able to accomodate digits like $-931.76 .but if the digit exceed this , then $ and minus sign remain on one line and value goes down to next line. Again if any of the...
6
2814
by: COSA200 | last post by:
Hello all. Im new to html, and have started a website, very basic, but it suits me. My question is, i want to add some links to the left hand side of my home page, with the welcome text in the middle of the page,how do i align left the links please in the boxes i have created. My site is http://itsa40.co.uk/index.html please advise alan
0
7546
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7740
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7830
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6071
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5387
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1082
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
784
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.