0

Alright i am trying not to use HTML tables at all possible now a days. But i am using CSS tables but i am wondering if there is an equivalent of colspan in CSS tables.

I have this code

#fleetTable{display: table;width: 360px;margin: 0 auto;margin-top: 20px;font-size:.875em;float:left;}
    .fleetRow{display: table-row;}
    .fleetCell{display: table-cell;}

And this HTML

<div id="fleetTable">
    <div class="fleetRow textright">
        <div class="fleetCell">Headline</div> <!-- I would like this to span both columns below but be centered -->
    </div>
    <div class="fleetRow textright">
        <div class="fleetCel;">Cell1</div>
        <div class="fleetCell">Cell2</div>
    </div>
</div>  

What selector would you use here to accomplish this?

Travis
  • 2,185
  • 7
  • 27
  • 42
  • possible duplicate of [table-cell - some kind of colspan?](http://stackoverflow.com/questions/9851582/table-cell-some-kind-of-colspan) – Quentin Sep 13 '13 at 20:51
  • 1
    Don't go overboard. It's totally OK to use tables to lay out tabular data. If what you have really is a table of data, then for heaven's sake use a table. Don't use tables to do *page* layout. – Ian McLaird Sep 13 '13 at 20:52
  • Yeah it was duplicate but google didnt give me that result @Quentin but thanks for the link that will work. – Travis Sep 13 '13 at 20:57
  • @IanMcLaird it is such a battle of where to use them and where to not. I was taught to use them way back when and then after learning real CSS layouts i have tried to stay away – Travis Sep 13 '13 at 20:58

1 Answers1

1

I am making an obvious assumption that your header will be the first cell of the first row and which having the .fleetCell class. So you can select this first element using :first-child pseudo selector like this.

CSS

.fleetCell:first-child{
   text-align:center;
}

JS Fiddle Example

Sachin
  • 40,216
  • 7
  • 90
  • 102
  • Interesting way of doing this. Your assumption is correct, this needs support for IE7 and IE8 uggghhhh but thanks for the answer. I really need to use pseudo elements more for things like this. – Travis Sep 13 '13 at 21:08