views:

42

answers:

1

I know this has been asked before but im curious to see if things have changed.

I'm looking for a html/css fixed 3 column layout with the main content (middle) area located first (of the 3 columns) in the DOM - for SEO.

Any ideas?

+2  A: 

It requires a bit extra markup, but to get the content to be first, you can try something like this:

<div id="wrapper">
    <div id="content-wrapper">
        <div id="content">I'm first</div>
        <div id="side_a">I'm second</div>
    </div>
    <div id="side_b">I'm third</div>
</div>

And in CSS:

#wrapper {
    width: 800px; /* Total width of all columns */
    margin: 0 auto;
}

#content-wrapper {
    float: left;
}

#content {
    width: 400px;
    float: right;
}

#side_a {
    width: 200px;
    float: left;
}

#side_b {
    float: left;
    width: 200px;
}

#wrapper contstraints the columns to the width of 800px and makes the page centered. The #content and #side_a columns are arranged inside #content_wrapper in reverse order using different floats. #side_b is then floated alongside #content_wrapper.

A working example can be found here:

http://www.ulmanen.fi/stuff/columns.php

Tatu Ulmanen
I like this approach but wondering if theres a way of achieving the same results without the content-wrapper. I think there is but we would have to use negative margins which im not a fan of. Any thoughts??
Meander365
One way is to use relative positioning, I was going to suggest that first but in my opinion that's sub-optimal. The way it would work is that you had Content, A and B floated next to each other with `float: left`, Content and A has `position: relative`, Content has `left: 200px` and A `left: -400px`. It works, but in my opinion it's not very nice.
Tatu Ulmanen