Solution Time.
Ok time to wrap this up and provide explanations.
Thanks to all that took part and nice to see a few new names as well as the regulars. All support is greatly received.
The requirements of the quiz were to get that little red block to the right of that widthless float in IE7 and under as presently the right floated block pushes iE7 to 100% wide.
The solution that I was looking for needed to maintain the flow of the document so those of you that used position:absolute to create the effect were close but no cigar I'm afraid. The problem with absolutely placing the element is that it relied on the left float being present and being the same size or bigger than the element on the right and wouldn't be usable in a real situation. Well done those of you who sent me the absolute solution as I think nearly everyone sent me that first 
The real answer was very simple indeed and only needed two minor changes for IE7.
Code:
.wrap{text-align:right}
.fr{float:none}
That was all you needed to do 
If you are wondering why this works then you have to go back to IE5 and remember that text-align:center on a parent will centre block level children.
This behaviour is still present in IE6 and 7 and what you may not have realised is that if you use text-align:right on the parent then the child block element will align to the right.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
body {text-align:right}
div {
width:300px;
height:300px;
background:red;
}
</style>
</head>
<body>
<div>test</div>
</body>
</html>
So all you need to have two elements in a row is to float the first element and then let the second element align to the right.
Here is the full solution:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
p {
margin:0
}
.wrap {
float:left;/* no width allowed*/
clear:left;
border:1px solid #ccc;
padding:10px;
margin:0 0 10px;
background:#f2f2f2;
}
.image {
height:150px;
border:1px solid #000;
background:red;
line-height:150px;
text-align:center;
}
.i1 {width:300px}
.i2 {width:400px}
.i3 {width:200px}
.f {
width:75px;
height:75px;
border:5px solid red;
text-align:center;
margin:1px 0 0;
background:#ffc;
}
.fl {float:left}
.fr {float:right}
</style>
<!--[if lte IE 7]>
<style type="text/css">
.wrap{text-align:right}
.fr{float:none}
</style>
<![endif]-->
</head>
<body>
<div class="wrap">
<p class="image i1">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i2">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i3">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
</body>
</html>
Some of you missed that behaviour and instead used the fact that you can turn a block element into an inline-block element by declaring it as inline then applying haslayout. This has the same effect as before in that the element is now subject to the text-align properties and you can align it to the right.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
p {
margin:0
}
.wrap {
float:left;/* no width allowed*/
clear:left;
border:1px solid #ccc;
padding:10px;
margin:0 0 10px;
background:#f2f2f2;
}
.image {
height:150px;
border:1px solid #000;
background:red;
line-height:150px;
text-align:center;
}
.i1 {width:300px}
.i2 {width:400px}
.i3 {width:200px}
.f {
width:75px;
height:75px;
border:5px solid red;
text-align:center;
margin:1px 0 0;
background:#ffc;
}
.fl {float:left}
.fr {float:right}
</style>
<!--[if lte IE 7]>
<style type="text/css">
.wrap{text-align:right}
.fr{float:none;display:inline-block}
.fr{display:inline}
</style>
<![endif]-->
</head>
<body>
<div class="wrap">
<p class="image i1">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i2">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i3">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
</body>
</html>
Thanks to all that took part: Gary Turner, Rayzur, EricWatson, Ryan, jeremyasnyder, rainmakr, Catharsis, Kingcool68, Poetro and Yurikolvsky (hope I've not missed anyone) .
The Winner IS:
Rayzur
Well done Ray 
The quickest Entry and a close second was Gary turner - well done Gary 
I chose ray's as the winning entry because the same code worked for all browsers without any hacks or alternative code.
Ray:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Quiz-33 Rayzur</title>
<style type="text/css">
p {
margin:0
}
.wrap {
float:left;/* no width allowed*/
clear:left;
border:1px solid #ccc;
padding:10px;
margin:0 0 10px;
background:#f2f2f2;
text-align:right;/*added this*/
}
.image {
height:150px;
border:1px solid #000;
background:red;
line-height:150px;
text-align:center;
}
.i1 {width:300px}/* cater for any width automatically*/
.i2 {width:400px}
.i3 {width:200px}
.f {
width:75px;
height:75px;
border:5px solid red;
text-align:center;
margin:1px 0 0;
background:#ffc;
}
.fl {float:left}
.fr {display:inline-block;}/*removed float*/
</style>
</head>
<body>
<div class="wrap">
<p class="image i1">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i2">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i3">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
</body>
</html>
Gary:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
p {
margin:0
}
.wrap {
float:left;/* no width allowed*/
clear:left;
border:1px solid #ccc;
padding:10px;
margin:0 0 10px;
background:#f2f2f2;
}
.image {
height:150px;
border:1px solid #000;
background:red;
line-height:150px;
text-align:center;
}
.i1 {width:300px}/* cater for any width automatically*/
.i2 {width:400px}
.i3 {width:200px}
.f {
width:75px;
height:75px;
border:5px solid red;
text-align:center;
margin:1px 0 0;
background:#ffc;
}
.fl {float:left}
.fr {float:right}
</style>
<!--[if lte IE 7]>
<style type="text/css">
.wrap {
text-align: right;
}
.fr {
display: inline-block;
float: none;
text-align: center;
}
</style>
<![endif]-->
</head>
<body>
<div class="wrap">
<p class="image i1">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i2">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i3">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
</body>
</html>
Eric Watson:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
p {
margin:0;
}
.wrap {
float:left;/* no width allowed*/
clear:left;
border:1px solid #ccc;
padding:10px;
margin:0 0 10px;
background:#f2f2f2;
}
.image {
height:150px;
border:1px solid #000;
background:red;
line-height:150px;
text-align:center;
}
.i1 {width:300px}/* cater for any width automatically*/
.i2 {width:400px}
.i3 {width:200px}
.f {
width:75px;
height:75px;
border:5px solid red;
text-align:center;
margin:1px 0 0;
background:#ffc;
}
.fl { float:left}
.fr { float:right}
</style>
<!--[if lte IE 7]>
<style type="text/css">
.wrap {text-align:right;}
.fr { float:none;}
</style>
<![endif]-->
</head>
<body>
<div class="wrap">
<p class="image i1">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i2">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i3">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
</body>
</html>
Rainmakr:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
p {
margin:0
}
.wrap {
float:left;/* no width allowed*/
clear:left;
border:1px solid #ccc;
padding:10px;
margin:0 0 10px;
background:#f2f2f2;
}
.image {
height:150px;
border:1px solid #000;
background:red;
line-height:150px;
text-align:center;
}
.i1 {width:300px}/* cater for any width automatically*/
.i2 {width:400px}
.i3 {width:200px}
.f {
width:75px;
height:75px;
border:5px solid red;
text-align:center;
margin:1px 0 0;
background:#ffc;
}
.fl {float:left}
.fr {float:right}
</style>
<!--[if lte IE 7]>
<style type="text/css">
.wrap {text-align:right;}
.wrap * {text-align:center;}
.fr {float:none; margin:1px 10px 0 0;}
</style>
<![endif]-->
</head>
<body>
<div class="wrap">
<p class="image i1">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i2">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i3">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
</body>
</html>
Catharsis:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
p {
margin:0
}
.wrap {
float:left;/* no width allowed*/
clear:left;
border:1px solid #ccc;
padding:10px;
margin:0 0 10px;
background:#f2f2f2;
}
.image {
height:150px;
border:1px solid #000;
background:red;
line-height:150px;
text-align:center;
}
.i1 {width:300px}/* cater for any width automatically*/
.i2 {width:400px}
.i3 {width:200px}
.f {
width:75px;
height:75px;
border:5px solid red;
text-align:center;
margin:1px 0 0;
background:#ffc;
}
.fl {float:left}
.fr {float:right}
</style>
<!--[if lte IE 7]>
<style type="text/css">
.wrap { text-align: right;}
.fr { float: none; }
</style>
<![endif]-->
</head>
<body>
<div class="wrap">
<p class="image i1">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i2">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i3">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
</body>
</html>
Yurikolovsky:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
p {
margin:0
}
.wrap {
float:left;/* no width allowed*/
clear:left;
border:1px solid #ccc;
padding:10px;
margin:0 0 10px;
background:#f2f2f2;
}
.image {
height:150px;
border:1px solid #000;
background:red;
line-height:150px;
text-align:center;
}
.i1 {width:300px}/* cater for any width automatically*/
.i2 {width:400px}
.i3 {width:200px}
.f {
width:75px;
height:75px;
border:5px solid red;
text-align:center;
margin:1px 0 0;
background:#ffc;
}
.fl {float:left}
.fr {float:right}
.fr {
float:none;
display:inline-block;
}
.wrap {
text-align:right;
}
</style>
</head>
<body>
<div class="wrap">
<p class="image i1">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i2">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i3">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
</body>
</html>
As an example of the absolute method I will just post one entry at Random but as mentioned above this is not the best way to do this:
Jeremeyasnyder
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
p {
margin:0;
}
.wrap {
float:left;/* no width allowed*/
clear: left;
border:1px solid #ccc;
padding:10px;
margin:0 0 10px;
background:#f2f2f2;
position: relative;
}
.image {
height:150px;
border:1px solid #000;
background:red;
line-height:150px;
text-align:center;
}
.i1 {width:300px}/* cater for any width automatically*/
.i2 {width:400px}
.i3 {width:200px}
.f {
width:75px;
height:75px;
border:5px solid red;
text-align:center;
margin:1px 0 0;
background:#ffc;
}
.fl {float:left;}
.fr {float: right;}
</style>
<!--[if lte IE 7]>
<style type="text/css">
.fr {
float: none;
position: absolute;
right: 10px;
}
</style>
<![endif]-->
</head>
<body>
<div class="wrap">
<p class="image i1">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i2">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
<div class="wrap">
<p class="image i3">Image</p>
<p class="f fl">Text Left<br>Text Left</p>
<p class="f fr">Text Right<br>Text Right</p>
</div>
</body>
</html>
Well done to all that took part and hope that you find this useful as it has real value in certain situations for IE7. (It could even be used for round corners to stop the 1px jog that you get with absolute elements placed in the corners in IE.)
Remember to fix your sights on a new quiz coming your way very soon
Bookmarks