View Full Version : Forget tables.. I need CSS...

03-19-2005, 10:31 PM
I'm working on my own website at the moment and I'm aiming to avoid tables as much as possible using plenty of CSS.

One question:

To achieve a band across the page containing two adjacent boxes I previously did this.

<table width="100%" height="100" cellpadding="0" cellspacing="0">
<td width="500" bgcolor="#EEEEEE">Something here</td>
<td bgcolor="#FAFAFA">This is at the right and fills the remaining width</td>

See it fills the entire page width, shows as two blocks but the left one is a fixed width. With CSS I'm pulling my hair out trying to get it working in both IE and CSS using XHTML Strict. I'm trying (except I'm using an external stylesheet):

<div style="width:500px; height:100px; padding:0px; margin:0px; background-color:#EEEEEE; display:block; float:left">
Something here
<div stlye="height:100px; padding:0px; margin:0px; background-color:#FAFAFA; display:block; float:left">
This is at the right and fills the remaining width

Can somebody help me out please :( It's getting the right hand side DIV to fill the remaining width that's causing me the headeache.

03-19-2005, 10:54 PM
you may be able to try something like width:inherit; im not too sure on how many browsers support this, IE doesn't display it properly it leaves a slight gap, FF does it right though go figure, but you may be able to disguise the bug by making the containing div the same background color as the div that is using width:inherit; or make the div not have a background color and just set the background color to the containing div

<div style="width:100%;">
<div style="width:500px; height:100px; padding:0px; margin:0px; background-color:#EEEEEE; float:left">
Something here
<div style="width:inherit; height:100px; padding:0px; margin:0px; background-color:#FAFAFA;">This is at the right and fills the remaining width</div>
if you float the second div width:inherit doesn't work

03-19-2005, 11:26 PM
Thanks I'll give it a go. IE is always a pain :thumbsup:

03-20-2005, 12:10 AM
OK I tried it but in IE it has a small gap as you say, and in NS / Moz it stretches the inherited div to 100% (overlapping).

Man, tables were so much easier LOL :rolleyes:

03-20-2005, 03:52 AM
works fine for me

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<title>RailEurope - Article page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body {

<div style="width:100%;background-color:#FAFAFA;">
<div style="width:500px; height:100px; background-color:#EEEEEE; float:left;">Something here
<div style="width:inherit; height:100px;">This is at the right and fills the remaining width</div>
o you shouldn't be displaying an element that is already a block element as block again, you had display:block; for your first div that might be the problem