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

text-align left AND text-align-right in same container (on same line)

P: n/a
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!!
Sep 21 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
gil


At approximately 2006/09/21 15:46, Sjef Janssen typed these characters:
>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!!

How about a div containing two divs. The inner divs could be aligned
separately
sample below has a different color border around each box but share the
same background color.

Gil

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Alignment test</title>
<style>
#container{background-color:pink;border:1px solid black; width:220px}
#left {margin:0;padding:0;border:1px solid blue;width:100px;
text-align:left; display:block; float:left;}
#right {margin:0;padding:0;border:1px solid red;width:100px;
text-align:right; display:block; float:right;}
</style>
</head>

<body>
<div id="container">
<div id="left">This text should be aligned to the left</div>
<div id="right">But this text should be aligned to the right</div>
</div>
</body>
</html>
Sep 21 '06 #2

P: n/a
"Sjef Janssen" <ma*************@planet.nlwrote:
>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).
Why, what are you trying to do?

--
Spartanicus
Sep 21 '06 #3

P: n/a
My first idea was to solve it with a table inside the box, But that's not
CSS is it? The container idea with the two div's inside solves it as well,
now with CSS! Thanks for thinking with me!!

Sjef

"Sjef Janssen" <ma*************@planet.nlschreef in bericht
news:45**********************@text.nova.planet.nl. ..
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!!


Sep 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.