I'm trying to develop a two column page. I can float the div to the right, but it doesn't line up flush with the right margin. Here is the Website with the code:
I suspect this is where my problem lies, but I can't be sure. If someone could please take a look at the simple code, I would appreciate it. Naturally, it is best viewed with Mozilla. Explorer doesn't render it as intended.
The page is rendering correctly. The width of the div element is equivalent to its width property plus its padding and border widths, thus, if we take a box of 200 px with a border value of 2px the actual visual width of the box is 204 px.
I've played around with changing widths on the various elements, and one thing that works is to reduce the width of the top header box by 6 pixels, to 394, and to reduce the width of the left-side element also by 6 pixels, to 194.
Alternatively, I can enter 406px for the width of the allcontent div and reset the two other divs (header and main) to 400px and 200px, respectively.
Both methods allow the borders to not overlap between the left-side element and the floated element, and for the header to line up on top. So I'm thinking that the default border width value must be 3px, and not 2. I verified this by entering 3px for the main and floated element, and the layout was unaltered.
And this, of course, only works in W3C compliant browsers. IE doesn't respect any of this.
Just a matter of floating the other elements, but you may want to increase the container div to 403, as previously stated to accommodate for those borders, and also set the width of the borders too:
Your code resulted in the header div being on top of the dotted border sidebar div, with the solid border main div directly underneath the sidebar div.
I don't understand why you would want to float the header div? For me, removing it made no difference.
Bookmarks