f



How to have left and right aligned text on same line?

Hi,

I wish to have text both left and right
aligned on the same line.  This is so
appropriate bits of text will fall under
either of a pair of images floated left and
right.  I have tried something like:

CSS file:
     span.right {text-align: right}

HTML file:
     <p>
     The Isle of Man, where I was born and grew up.
     <span class="right">Canada, where I choose to live.</span>
     </p>

but it doesn't appear to work.  I guess this
is because 'text-align' applies to block
containers, and so to the whole paragraph
(not part of it).

Is there another way of doing this using
CSS/HTML?

To see it in context, visit:
http://members.tripod.com/martin_leese/

and scroll down to the two flags.

Thanks in advance for any suggestions.
-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
0
Martin
9/11/2011 1:27:41 AM
comp.authoring.stylesheets 8158 articles. 0 followers. mdmoura (161) is leader. Post Follow

19 Replies
717 Views

Similar Articles

[PageSpeed] 47

In article <j4h2qm$tso$1@dont-email.me>,
 Martin Leese <please@see.Web.for.e-mail.INVALID> wrote:

> Hi,
> 
> I wish to have text both left and right
> aligned on the same line.  This is so
> appropriate bits of text will fall under
> either of a pair of images floated left and
> right.  I have tried something like:
> 

Many ways. One is 


..class1 {float: left; width: 200px;}
..class2 {float: right; width: 200px;}


<div class="class1"><img src="pic1.png" alt=""><br>text under 
img</div>
<div class="class2"><img src="pic2.png" alt=""><br>text under 
img</div>

You can width divs according to size of your pictures

-- 
dorayme
0
dorayme
9/11/2011 2:43:36 AM
On 9/10/2011 9:27 PM, Martin Leese wrote:
> Hi,
>
> I wish to have text both left and right
> aligned on the same line. This is so
> appropriate bits of text will fall under
> either of a pair of images floated left and
> right. I have tried something like:
>
> CSS file:
> span.right {text-align: right}
>
> HTML file:
> <p>
> The Isle of Man, where I was born and grew up.
> <span class="right">Canada, where I choose to live.</span>
> </p>
>
> but it doesn't appear to work. I guess this
> is because 'text-align' applies to block
> containers, and so to the whole paragraph
> (not part of it).
>
> Is there another way of doing this using
> CSS/HTML?
>
> To see it in context, visit:
> http://members.tripod.com/martin_leese/
>
> and scroll down to the two flags.


text-align: right
CSS2.1 stipulates that it applies only to block-level elements, table 
cells and inline blocks (block of text (i.e. paragraph) set Flush right 
(ragged Left)).
   So, if you add as per:
       span.right {text-align: right; display:block;}
   it will work, except you will have to make further changes to place
   both items on the same line.

float:right
   Slams the div, img, span, whatever, right it up against the right
   margin.
   So, if you simply change the stylesheet to:
       span.right {float:right;}
   it will place the two text sections under their respective flags as
   desired and on the same line.

-- 
Gus

0
Gus
9/11/2011 4:01:01 AM
Gus Richter wrote:

> text-align: right
> CSS2.1 stipulates that it applies only to block-level elements, table 
> cells and inline blocks (block of text (i.e. paragraph) set Flush right 
> (ragged Left)).
>   So, if you add as per:
>       span.right {text-align: right; display:block;}
>   it will work, except you will have to make further changes to place
>   both items on the same line.
> 
> float:right
>   Slams the div, img, span, whatever, right it up against the right
>   margin.
>   So, if you simply change the stylesheet to:
>       span.right {float:right;}
>   it will place the two text sections under their respective flags as
>   desired and on the same line.

This second suggestion almost did what I
wanted.  The two text sections were still on
different lines, but adding:
     span.left {float:left}

to the left section as well pushed them onto
the same line.  The final result is again at:
http://members.tripod.com/martin_leese/

if you scroll down to the two flags.

Many thanks for your help.
-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
0
Martin
9/13/2011 5:32:59 AM
On 9/13/2011 1:32 AM, Martin Leese wrote:
> Gus Richter wrote:
>
>> text-align: right
>> CSS2.1 stipulates that it applies only to block-level elements, table
>> cells and inline blocks (block of text (i.e. paragraph) set Flush
>> right (ragged Left)).
>> So, if you add as per:
>> span.right {text-align: right; display:block;}
>> it will work, except you will have to make further changes to place
>> both items on the same line.
>>
>> float:right
>> Slams the div, img, span, whatever, right it up against the right
>> margin.
>> So, if you simply change the stylesheet to:
>> span.right {float:right;}
>> it will place the two text sections under their respective flags as
>> desired and on the same line.
>
> This second suggestion almost did what I
> wanted. The two text sections were still on
> different lines, but adding:
> span.left {float:left}
>
> to the left section as well pushed them onto
> the same line. The final result is again at:
> http://members.tripod.com/martin_leese/
>
> if you scroll down to the two flags.
>
> Many thanks for your help.

Seeing as you are using a very old version of Thunderbird (anno 2007), I 
assume you are also using a very old browser. My up to date versions of 
Firefox, Chrome, Safari, Opera and IE8 display correctly with only one 
span floated. I checked with my IE6 and it displays as you describe. 
Your modification of floating both spans, although not needed (for 
modern browsers), does no harm.

BTW,
<http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fmembers.tripod.com%2Fmartin_leese%2F>
<http://jigsaw.w3.org/css-validator/validator?profile=css21&warning=0&uri=http%3A%2F%2Fmembers.tripod.com%2Fmartin_leese%2F>

-- 
Gus

0
Gus
9/13/2011 9:54:56 AM
Gus Richter wrote:

> Seeing as you are using a very old version of Thunderbird (anno 2007), I 
> assume you are also using a very old browser. 

You bet.  I use Firefox 1.5.0.12 (2007),
Netscape 7.02 (2003), and IE 5.50 (2000).
To upgrade my browsers I would have to
upgrade my OS (and to upgrade my OS I
would first have to buy a new computer).

> My up to date versions of 
> Firefox, Chrome, Safari, Opera and IE8 display correctly with only one 
> span floated. I checked with my IE6 and it displays as you describe. 
> Your modification of floating both spans, although not needed (for 
> modern browsers), does no harm.

Good to know.

> BTW,
> <http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fmembers.tripod.com%2Fmartin_leese%2F> 
> 
> <http://jigsaw.w3.org/css-validator/validator?profile=css21&warning=0&uri=http%3A%2F%2Fmembers.tripod.com%2Fmartin_leese%2F> 

This is all crap added by my Web hosting
company, Tripod.  (It is the price I pay
for free Web hosting.)  When I upload my
files, they validate with only one error
(which I will now fix).

Thanks again for your help.
-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
0
Martin
9/13/2011 4:41:01 PM
Martin Leese wrote:
>
> You bet.  I use Firefox 1.5.0.12 (2007),
> Netscape 7.02 (2003), and IE 5.50 (2000).
> To upgrade my browsers I would have to
> upgrade my OS (and to upgrade my OS I
> would first have to buy a new computer).

What are you still on Win98?

-- 
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
0
Jonathan
9/13/2011 5:22:15 PM
On 9/13/2011 12:41 PM, Martin Leese wrote:
> Gus Richter wrote:
>
>> Seeing as you are using a very old version of Thunderbird (anno 2007),
>> I assume you are also using a very old browser.
>
> You bet. I use Firefox 1.5.0.12 (2007),
> Netscape 7.02 (2003), and IE 5.50 (2000).
> To upgrade my browsers I would have to
> upgrade my OS (and to upgrade my OS I
> would first have to buy a new computer).


*Whoa!*

-- 
Gus

0
Gus
9/13/2011 9:00:57 PM
* Jonathan N. Little wrote in ciwas:
>Martin Leese wrote:
>>
>> You bet.  I use Firefox 1.5.0.12 (2007),
>> Netscape 7.02 (2003), and IE 5.50 (2000).
>> To upgrade my browsers I would have to
>> upgrade my OS (and to upgrade my OS I
>> would first have to buy a new computer).
>
>What are you still on Win98?

IE6 should run fine under Windows 98, so it's more likely to be 95. I
note that Opera 10.x should run under Windows 95, which was current a
year ago; I would give using that instead serious consideration.
-- 
Bj�rn H�hrmann � mailto:bjoern@hoehrmann.de � http://bjoern.hoehrmann.de
Am Badedeich 7 � Telefon: +49(0)160/4415681 � http://www.bjoernsworld.de
25899 Dageb�ll � PGP Pub. KeyID: 0xA4357E78 � http://www.websitedev.de/ 
0
Bjoern
9/13/2011 9:52:37 PM
Bjoern Hoehrmann wrote:
> * Jonathan N. Little wrote in ciwas:
>> Martin Leese wrote:
>>>
>>> You bet.  I use Firefox 1.5.0.12 (2007),
>>> Netscape 7.02 (2003), and IE 5.50 (2000).
>>> To upgrade my browsers I would have to
>>> upgrade my OS (and to upgrade my OS I
>>> would first have to buy a new computer).
>>
>> What are you still on Win98?
>
> IE6 should run fine under Windows 98, so it's more likely to be 95. I
> note that Opera 10.x should run under Windows 95, which was current a
> year ago; I would give using that instead serious consideration.

My point was going to be there are more modern options for older OSes. 
There are some with XP still using IE5...they never realized they could 
upgrade.

-- 
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
0
Jonathan
9/13/2011 10:27:35 PM
On Tue, 13 Sep 2011 17:00:57 -0400, Gus Richter
<gusrichter@netscape.net> wrote:

>*Whoa!*

Isn't that what equestrians say to their horses when they want them to
stop? There's not much point telling Martin to stop; he obviously
ground to a complete halt years ago! But then I'm on XP, so who am I
to speak? :-) (Noting that Windows 8 gets a mention on the BBC website
today)

-- 
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk
0
Swifty
9/14/2011 7:33:20 AM
On 9/14/2011 3:33 AM, Swifty wrote:
> On Tue, 13 Sep 2011 17:00:57 -0400, Gus Richter
> <gusrichter@netscape.net>  wrote:
>
>> *Whoa!*
>
> Isn't that what equestrians say to their horses when they want them to
> stop? There's not much point telling Martin to stop; he obviously
> ground to a complete halt years ago! But then I'm on XP, so who am I
> to speak? :-) (Noting that Windows 8 gets a mention on the BBC website
> today)


<http://www.youtube.com/watch?v=wQ5iFQv1KaE>  ;)

-- 
Gus

0
Gus
9/14/2011 8:07:25 AM
Bjoern Hoehrmann wrote:

> * Jonathan N. Little wrote in ciwas:

>> Martin Leese wrote:
>>> You bet.  I use Firefox 1.5.0.12 (2007),
>>> Netscape 7.02 (2003), and IE 5.50 (2000).
>>> To upgrade my browsers I would have to
>>> upgrade my OS (and to upgrade my OS I
>>> would first have to buy a new computer).

>> What are you still on Win98?

> IE6 should run fine under Windows 98, so it's more likely to be 95.

Correct, Windows 95.

> I
> note that Opera 10.x should run under Windows 95, which was current a
> year ago; I would give using that instead serious consideration.

Thank you for the heads up, I will look into
this.

My other option is to migrate to Linux.  I
tried Mandrake a few years ago, but it had
problems with some of my hardware.
Hopefully a more recent version of Linux
will manage better.
-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
0
Martin
9/14/2011 5:21:35 PM
Martin Leese wrote:
> Bjoern Hoehrmann wrote:
>
>> * Jonathan N. Little wrote in ciwas:
>
>>> Martin Leese wrote:
>>>> You bet. I use Firefox 1.5.0.12 (2007),
>>>> Netscape 7.02 (2003), and IE 5.50 (2000).
>>>> To upgrade my browsers I would have to
>>>> upgrade my OS (and to upgrade my OS I
>>>> would first have to buy a new computer).
>
>>> What are you still on Win98?
>
>> IE6 should run fine under Windows 98, so it's more likely to be 95.
>
> Correct, Windows 95.

Way too old: totally unpatchable, and no anti-virus runnable, a hazard 
to be online.

>
>> I
>> note that Opera 10.x should run under Windows 95, which was current a
>> year ago; I would give using that instead serious consideration.
>
> Thank you for the heads up, I will look into
> this.
>
> My other option is to migrate to Linux. I
> tried Mandrake a few years ago, but it had
> problems with some of my hardware.
> Hopefully a more recent version of Linux
> will manage better.

A better option and at least to get an up to date patched OS, Maybe 
Puppy Linux. Damn Small Linux, or something of the ilk


-- 
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
0
Jonathan
9/14/2011 6:17:34 PM
Jonathan N. Little wrote:

> Martin Leese wrote:
>>>> Martin Leese wrote:
>>>>> You bet. I use Firefox 1.5.0.12 (2007),
>>>>> Netscape 7.02 (2003), and IE 5.50 (2000).
>>>>> To upgrade my browsers I would have to
>>>>> upgrade my OS (and to upgrade my OS I
>>>>> would first have to buy a new computer).
....
>> Correct, Windows 95.
> 
> Way too old: totally unpatchable, and no anti-virus runnable, a hazard 
> to be online.

Until a few weeks ago, I was running avast!
anti-virus.  But you are now correct, if
somebody develops a new virus targeted at
Windows 95 then I am at risk.

-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
0
Martin
9/16/2011 6:37:51 PM
Martin Leese wrote:
> Jonathan N. Little wrote:
>
>> Martin Leese wrote:
>>>>> Martin Leese wrote:
>>>>>> You bet. I use Firefox 1.5.0.12 (2007),
>>>>>> Netscape 7.02 (2003), and IE 5.50 (2000).
>>>>>> To upgrade my browsers I would have to
>>>>>> upgrade my OS (and to upgrade my OS I
>>>>>> would first have to buy a new computer).
> ...
>>> Correct, Windows 95.
>>
>> Way too old: totally unpatchable, and no anti-virus runnable, a hazard
>> to be online.
>
> Until a few weeks ago, I was running avast!
> anti-virus. But you are now correct, if
> somebody develops a new virus targeted at
> Windows 95 then I am at risk.
>

I just removed a rootkit from a friend's system running Avast...not too 
impressed.

If you have a real love for this hardware and it is at least a Pentium 
and you can scrounge some more RAM, it probably in the EDO and PC66 
error... then install something like Puppy Linux and get a working, 
safe, system. Puppy Linux will run on less, but a little more to the 
specs and it would have less "wait-time"

-- 
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
0
Jonathan
9/16/2011 8:07:47 PM
Martin Leese wrote:

 > Bjoern Hoehrmann wrote:
....
 >> I
 >> note that Opera 10.x should run under Windows 95, which was current a
 >> year ago; I would give using that instead serious consideration.
 >
 > Thank you for the heads up, I will look into
 > this.

Many thanks for this excellent suggestion.
I am now running Opera 10.10.  (This is the
latest release before support for Windows 95
was dropped.)  It is excellent.

-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
0
Martin
10/26/2011 4:30:38 PM
Martin Leese wrote:
> Jonathan N. Little wrote:
>
>> Martin Leese wrote:
>>>>> Martin Leese wrote:
>>>>>> You bet. I use Firefox 1.5.0.12 (2007),
>>>>>> Netscape 7.02 (2003), and IE 5.50 (2000).
>>>>>> To upgrade my browsers I would have to
>>>>>> upgrade my OS (and to upgrade my OS I
>>>>>> would first have to buy a new computer).
> ...
>>> Correct, Windows 95.
>>
>> Way too old: totally unpatchable, and no anti-virus runnable, a hazard
>> to be online.
>
> Until a few weeks ago, I was running avast!
> anti-virus. But you are now correct, if
> somebody develops a new virus targeted at
> Windows 95 then I am at risk.
>

Are you under the delusion the old viruses when when away? I bet there 
is still Jerusalem floating about on a floppy somewhere. Also viruses 
designed for XP does not necessary mean pre-XP versions are immune. As I 
said to run an unpatchable, no antivirus, MS OS online is insane.

A Win95 vintage system will be too-low spec to run a maintained secure 
OS other that a light desktop version of Linux.

-- 
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
0
Jonathan
10/26/2011 6:03:04 PM
Jonathan N. Little wrote:
> Martin Leese wrote:
>> Jonathan N. Little wrote:
>>
>>> Martin Leese wrote:
>>>>>> Martin Leese wrote:
>>>>>>> You bet. I use Firefox 1.5.0.12 (2007),
>>>>>>> Netscape 7.02 (2003), and IE 5.50 (2000).
>>>>>>> To upgrade my browsers I would have to
>>>>>>> upgrade my OS (and to upgrade my OS I
>>>>>>> would first have to buy a new computer).
>> ...
>>>> Correct, Windows 95.
>>>
>>> Way too old: totally unpatchable, and no anti-virus runnable, a hazard
>>> to be online.
>>
>> Until a few weeks ago, I was running avast!
>> anti-virus. But you are now correct, if
>> somebody develops a new virus targeted at
>> Windows 95 then I am at risk.
> 
> Are you under the delusion the old viruses when when away? I bet there 
> is still Jerusalem floating about on a floppy somewhere. Also viruses 
> designed for XP does not necessary mean pre-XP versions are immune. As I 
> said to run an unpatchable, no antivirus, MS OS online is insane.
> 
> A Win95 vintage system will be too-low spec to run a maintained secure 
> OS other that a light desktop version of Linux.

Thank you for your concern, but I am still
running avast!.  What I can no longer do is
*update* the virus database.

-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
0
Martin
10/27/2011 3:52:46 PM
Martin Leese wrote:

> Thank you for your concern, but I am still
> running avast!. What I can no longer do is
> *update* the virus database.
>

Not solely altruistic, is insecure systems likes yours that become the 
bots that pump spam into my inbox. It is just irresponsible and foolish.

Antivirus with outdated definitions is worst than no antivirus because 
you are deluded and thinking that you are protected. The way traditional 
antivirus works is by looking for a distinct "tag" or "signature" in the 
rogue program. The blackhats do not reinvent the wheel for each new 
virus, too much unnecessary work. Often they just change the the tag. So 
you can get infected by an "old goodie" that has only had the tag 
changed if you use outdated antivirus definitions.

-- 
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
0
Jonathan
10/27/2011 5:41:43 PM
Reply: