tables.md 16.5 KB
Newer Older
Mark Otto's avatar
Mark Otto committed
1
---
Mark Otto's avatar
Mark Otto committed
2
layout: docs
Mark Otto's avatar
Mark Otto committed
3
title: Tables
Mark Otto's avatar
Mark Otto committed
4
group: content
Mark Otto's avatar
Mark Otto committed
5
6
---

Mark Otto's avatar
Mark Otto committed
7
Due to the widespread use of tables across third-party widgets like calendars and date pickers, we've designed our tables to be **opt-in**. Just add the base class `.table` to any `<table>`, then extend with custom styles or our various included modifier classes.
Mark Otto's avatar
Mark Otto committed
8

Mark Otto's avatar
Mark Otto committed
9
10
11
12
13
## Contents

* Will be replaced with the ToC, excluding the "Contents" header
{:toc}

Mark Otto's avatar
Mark Otto committed
14
15
16
## Examples

Using the most basic table markup, here's how `.table`-based tables look in Bootstrap.
Mark Otto's avatar
Mark Otto committed
17
18
19
20
21
22
23
24
25
26
27
28
29

{% example html %}
<table class="table">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
Mark Otto's avatar
Mark Otto committed
30
      <th scope="row">1</th>
Mark Otto's avatar
Mark Otto committed
31
32
33
34
35
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
36
      <th scope="row">2</th>
Mark Otto's avatar
Mark Otto committed
37
38
39
40
41
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
42
      <th scope="row">3</th>
Mark Otto's avatar
Mark Otto committed
43
44
45
46
47
48
49
50
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>
{% endexample %}

Mark Otto's avatar
Mark Otto committed
51
You can also invert the colors—with light text on dark backgrounds—with `.table-inverse`.
Mark Otto's avatar
Mark Otto committed
52
53
54
55
56
57
58
59
60
61
62
63
64

{% example html %}
<table class="table table-inverse">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
Mark Otto's avatar
Mark Otto committed
65
      <th scope="row">1</th>
Mark Otto's avatar
Mark Otto committed
66
67
68
69
70
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
71
      <th scope="row">2</th>
Mark Otto's avatar
Mark Otto committed
72
73
74
75
76
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
77
      <th scope="row">3</th>
Mark Otto's avatar
Mark Otto committed
78
79
80
81
82
83
84
85
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>
{% endexample %}

Mark Otto's avatar
Mark Otto committed
86
87
## Table head options

Mark Otto's avatar
Mark Otto committed
88
Similar to default and inverse tables, use one of two modifier classes to make `<thead>`s appear light or dark gray.
Mark Otto's avatar
Mark Otto committed
89
90
91
92
93
94
95
96
97
98
99
100
101

{% example html %}
<table class="table">
  <thead class="thead-inverse">
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
Mark Otto's avatar
Mark Otto committed
102
      <th scope="row">1</th>
Mark Otto's avatar
Mark Otto committed
103
104
105
106
107
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
108
      <th scope="row">2</th>
Mark Otto's avatar
Mark Otto committed
109
110
111
112
113
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
114
      <th scope="row">3</th>
Mark Otto's avatar
Mark Otto committed
115
116
117
118
119
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
120
121
122
</table>

<table class="table">
Mark Otto's avatar
Mark Otto committed
123
124
125
126
127
128
129
130
131
132
  <thead class="thead-default">
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
Mark Otto's avatar
Mark Otto committed
133
      <th scope="row">1</th>
Mark Otto's avatar
Mark Otto committed
134
135
136
137
138
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
139
      <th scope="row">2</th>
Mark Otto's avatar
Mark Otto committed
140
141
142
143
144
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
145
      <th scope="row">3</th>
Mark Otto's avatar
Mark Otto committed
146
147
148
149
150
151
152
153
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>
{% endexample %}

Mark Otto's avatar
Mark Otto committed
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
## Striped rows

Use `.table-striped` to add zebra-striping to any table row within the `<tbody>`.

{% example html %}
<table class="table table-striped">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
Mark Otto's avatar
Mark Otto committed
170
      <th scope="row">1</th>
Mark Otto's avatar
Mark Otto committed
171
172
173
174
175
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
176
      <th scope="row">2</th>
Mark Otto's avatar
Mark Otto committed
177
178
179
180
181
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
182
      <th scope="row">3</th>
Mark Otto's avatar
Mark Otto committed
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>
{% endexample %}

## Bordered table

Add `.table-bordered` for borders on all sides of the table and cells.

{% example html %}
<table class="table table-bordered">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
207
      <th scope="row">1</th>
Mark Otto's avatar
Mark Otto committed
208
209
210
211
212
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
213
      <th scope="row">2</th>
Mark Otto's avatar
Mark Otto committed
214
215
216
217
218
      <td>Mark</td>
      <td>Otto</td>
      <td>@TwBootstrap</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
219
      <th scope="row">3</th>
Mark Otto's avatar
Mark Otto committed
220
221
222
223
224
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
225
      <th scope="row">4</th>
Mark Otto's avatar
Mark Otto committed
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
      <td colspan="2">Larry the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>
{% endexample %}

## Hoverable rows

Add `.table-hover` to enable a hover state on table rows within a `<tbody>`.

{% example html %}
<table class="table table-hover">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
Mark Otto's avatar
Mark Otto committed
249
      <th scope="row">1</th>
Mark Otto's avatar
Mark Otto committed
250
251
252
253
254
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
255
      <th scope="row">2</th>
Mark Otto's avatar
Mark Otto committed
256
257
258
259
260
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
261
      <th scope="row">3</th>
Mark Otto's avatar
Mark Otto committed
262
263
264
265
266
267
268
      <td colspan="2">Larry the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>
{% endexample %}

269
## Small table
Mark Otto's avatar
Mark Otto committed
270

271
Add `.table-sm` to make tables more compact by cutting cell padding in half.
Mark Otto's avatar
Mark Otto committed
272
273

{% example html %}
274
<table class="table table-sm">
Mark Otto's avatar
Mark Otto committed
275
276
277
278
279
280
281
282
283
284
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
Mark Otto's avatar
Mark Otto committed
285
      <th scope="row">1</th>
Mark Otto's avatar
Mark Otto committed
286
287
288
289
290
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
291
      <th scope="row">2</th>
Mark Otto's avatar
Mark Otto committed
292
293
294
295
296
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
297
      <th scope="row">3</th>
Mark Otto's avatar
Mark Otto committed
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
      <td colspan="2">Larry the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>
{% endexample %}

## Contextual classes

Use contextual classes to color table rows or individual cells.

<div class="table-responsive">
  <table class="table table-bordered table-striped">
    <colgroup>
      <col class="col-xs-1">
      <col class="col-xs-7">
    </colgroup>
    <thead>
      <tr>
        <th>Class</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
Mark Otto's avatar
Mark Otto committed
323
        <th scope="row">
324
          <code>.table-active</code>
Mark Otto's avatar
Mark Otto committed
325
        </th>
Mark Otto's avatar
Mark Otto committed
326
327
328
        <td>Applies the hover color to a particular row or cell</td>
      </tr>
      <tr>
Mark Otto's avatar
Mark Otto committed
329
        <th scope="row">
330
          <code>.table-success</code>
Mark Otto's avatar
Mark Otto committed
331
        </th>
Mark Otto's avatar
Mark Otto committed
332
333
334
        <td>Indicates a successful or positive action</td>
      </tr>
      <tr>
Mark Otto's avatar
Mark Otto committed
335
        <th scope="row">
336
          <code>.table-info</code>
Mark Otto's avatar
Mark Otto committed
337
        </th>
Mark Otto's avatar
Mark Otto committed
338
339
340
        <td>Indicates a neutral informative change or action</td>
      </tr>
      <tr>
Mark Otto's avatar
Mark Otto committed
341
        <th scope="row">
342
          <code>.table-warning</code>
Mark Otto's avatar
Mark Otto committed
343
        </th>
Mark Otto's avatar
Mark Otto committed
344
345
346
        <td>Indicates a warning that might need attention</td>
      </tr>
      <tr>
Mark Otto's avatar
Mark Otto committed
347
        <th scope="row">
348
          <code>.table-danger</code>
Mark Otto's avatar
Mark Otto committed
349
        </th>
Mark Otto's avatar
Mark Otto committed
350
351
352
353
354
355
        <td>Indicates a dangerous or potentially negative action</td>
      </tr>
    </tbody>
  </table>
</div>

356
<div class="bd-example">
Mark Otto's avatar
Mark Otto committed
357
358
359
360
361
362
363
364
365
366
  <table class="table">
    <thead>
      <tr>
        <th>#</th>
        <th>Column heading</th>
        <th>Column heading</th>
        <th>Column heading</th>
      </tr>
    </thead>
    <tbody>
367
      <tr class="table-active">
Mark Otto's avatar
Mark Otto committed
368
        <th scope="row">1</th>
Mark Otto's avatar
Mark Otto committed
369
370
371
372
373
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr>
Mark Otto's avatar
Mark Otto committed
374
        <th scope="row">2</th>
Mark Otto's avatar
Mark Otto committed
375
376
377
378
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
379
      <tr class="table-success">
Mark Otto's avatar
Mark Otto committed
380
        <th scope="row">3</th>
Mark Otto's avatar
Mark Otto committed
381
382
383
384
385
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr>
Mark Otto's avatar
Mark Otto committed
386
        <th scope="row">4</th>
Mark Otto's avatar
Mark Otto committed
387
388
389
390
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
391
      <tr class="table-info">
Mark Otto's avatar
Mark Otto committed
392
        <th scope="row">5</th>
Mark Otto's avatar
Mark Otto committed
393
394
395
396
397
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr>
Mark Otto's avatar
Mark Otto committed
398
        <th scope="row">6</th>
Mark Otto's avatar
Mark Otto committed
399
400
401
402
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
403
      <tr class="table-warning">
Mark Otto's avatar
Mark Otto committed
404
        <th scope="row">7</th>
Mark Otto's avatar
Mark Otto committed
405
406
407
408
409
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr>
Mark Otto's avatar
Mark Otto committed
410
        <th scope="row">8</th>
Mark Otto's avatar
Mark Otto committed
411
412
413
414
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
415
      <tr class="table-danger">
Mark Otto's avatar
Mark Otto committed
416
        <th scope="row">9</th>
Mark Otto's avatar
Mark Otto committed
417
418
419
420
421
422
423
424
425
426
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
    </tbody>
  </table>
</div>

{% highlight html %}
<!-- On rows -->
427
428
429
430
431
<tr class="table-active">...</tr>
<tr class="table-success">...</tr>
<tr class="table-warning">...</tr>
<tr class="table-danger">...</tr>
<tr class="table-info">...</tr>
Mark Otto's avatar
Mark Otto committed
432
433
434

<!-- On cells (`td` or `th`) -->
<tr>
435
436
437
438
439
  <td class="table-active">...</td>
  <td class="table-success">...</td>
  <td class="table-warning">...</td>
  <td class="table-danger">...</td>
  <td class="table-info">...</td>
Mark Otto's avatar
Mark Otto committed
440
441
442
</tr>
{% endhighlight %}

Mark Otto's avatar
Mark Otto committed
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
Regular table background variants are not available with the inverse table, however, you may use [text or background utilities](/components/utilities/#contextual-colors-and-backgrounds) to achieve similar styles.

<div class="bd-example">
  <table class="table table-inverse">
    <thead>
      <tr>
        <th>#</th>
        <th>Column heading</th>
        <th>Column heading</th>
        <th>Column heading</th>
      </tr>
    </thead>
    <tbody>
      <tr class="bg-primary">
        <th scope="row">1</th>
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr>
        <th scope="row">2</th>
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr class="bg-success">
        <th scope="row">3</th>
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr>
        <th scope="row">4</th>
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr class="bg-info">
        <th scope="row">5</th>
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr>
        <th scope="row">6</th>
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr class="bg-warning">
        <th scope="row">7</th>
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr>
        <th scope="row">8</th>
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
      <tr class="bg-danger">
        <th scope="row">9</th>
        <td>Column content</td>
        <td>Column content</td>
        <td>Column content</td>
      </tr>
    </tbody>
  </table>
</div>

Mark Otto's avatar
Mark Otto committed
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
{% highlight html %}
<!-- On rows -->
<tr class="bg-primary">...</tr>
<tr class="bg-success">...</tr>
<tr class="bg-warning">...</tr>
<tr class="bg-danger">...</tr>
<tr class="bg-info">...</tr>

<!-- On cells (`td` or `th`) -->
<tr>
  <td class="bg-primary">...</td>
  <td class="bg-success">...</td>
  <td class="bg-warning">...</td>
  <td class="bg-danger">...</td>
  <td class="bg-info">...</td>
</tr>
{% endhighlight %}

Mark Otto's avatar
Mark Otto committed
532
533
534
{% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %}
{{ callout-include | markdownify }}

Mark Otto's avatar
Mark Otto committed
535
536
537
538
## Responsive tables

Create responsive tables by wrapping any `.table` in `.table-responsive` to make them scroll horizontally on small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.

539
540
541
542
543
544
545
546
547
{% callout warning %}
#### Vertical clipping/truncation

Responsive tables make use of `overflow-y: hidden`, which clips off any content that goes beyond the bottom or top edges of the table. In particular, this can clip off dropdown menus and other third-party widgets.
{% endcallout %}

{% callout warning %}
#### Firefox and fieldsets

Thomas Shinnick's avatar
Thomas Shinnick committed
548
Firefox has some awkward fieldset styling involving `width` that interferes with the responsive table. This cannot be overridden without a Firefox-specific hack that we **don't** provide in Bootstrap:
Mark Otto's avatar
Mark Otto committed
549

Mark Otto's avatar
Mark Otto committed
550
551
552
553
554
{% highlight css %}
@-moz-document url-prefix() {
  fieldset { display: table-cell; }
}
{% endhighlight %}
555

Mark Otto's avatar
Mark Otto committed
556
For more information, read [this Stack Overflow answer](https://stackoverflow.com/questions/17408815/fieldset-resizes-wrong-appears-to-have-unremovable-min-width-min-content/17863685#17863685).
557
{% endcallout %}
Mark Otto's avatar
Mark Otto committed
558

559
<div class="bd-example">
Mark Otto's avatar
Mark Otto committed
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
  <div class="table-responsive">
    <table class="table">
      <thead>
        <tr>
          <th>#</th>
          <th>Table heading</th>
          <th>Table heading</th>
          <th>Table heading</th>
          <th>Table heading</th>
          <th>Table heading</th>
          <th>Table heading</th>
        </tr>
      </thead>
      <tbody>
        <tr>
Mark Otto's avatar
Mark Otto committed
575
          <th scope="row">1</th>
Mark Otto's avatar
Mark Otto committed
576
577
578
579
580
581
582
583
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
        </tr>
        <tr>
Mark Otto's avatar
Mark Otto committed
584
          <th scope="row">2</th>
Mark Otto's avatar
Mark Otto committed
585
586
587
588
589
590
591
592
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
        </tr>
        <tr>
Mark Otto's avatar
Mark Otto committed
593
          <th scope="row">3</th>
Mark Otto's avatar
Mark Otto committed
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
        </tr>
      </tbody>
    </table>
  </div>

  <div class="table-responsive">
    <table class="table table-bordered">
      <thead>
        <tr>
          <th>#</th>
          <th>Table heading</th>
          <th>Table heading</th>
          <th>Table heading</th>
          <th>Table heading</th>
          <th>Table heading</th>
          <th>Table heading</th>
        </tr>
      </thead>
      <tbody>
        <tr>
Mark Otto's avatar
Mark Otto committed
620
          <th scope="row">1</th>
Mark Otto's avatar
Mark Otto committed
621
622
623
624
625
626
627
628
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
        </tr>
        <tr>
Mark Otto's avatar
Mark Otto committed
629
          <th scope="row">2</th>
Mark Otto's avatar
Mark Otto committed
630
631
632
633
634
635
636
637
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
        </tr>
        <tr>
Mark Otto's avatar
Mark Otto committed
638
          <th scope="row">3</th>
Mark Otto's avatar
Mark Otto committed
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
          <td>Table cell</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

{% highlight html %}
<div class="table-responsive">
  <table class="table">
    ...
  </table>
</div>
{% endhighlight %}
658
659
660


### Reflow
661
662
663
664
665
666
667
668
669
670
Turn traditional tables on their side by using `table-reflow`. When using reflow, the table header becomes the first column of the table, the first row within the table body becomes the second column, the second row becomes the third column, etc.

{% callout warning %}
#### Content order and complex tables

Beware that the `table-reflow` style changes the visual order of content. Make sure that you only apply this style to well-formed and simple data tables (and in particular, don't use this for layout tables) with appropriate `<th>` table header cells for each row and column.

In addition, this class will not work correctly for tables with cells that span multiple rows or columns (using `rowspan` or `colspan` attributes).

{% endcallout %}
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686

{% example html %}
<table class="table table-reflow">
  <thead>
    <tr>
      <th>#</th>
      <th>Table heading</th>
      <th>Table heading</th>
      <th>Table heading</th>
      <th>Table heading</th>
      <th>Table heading</th>
      <th>Table heading</th>
    </tr>
  </thead>
  <tbody>
    <tr>
Mark Otto's avatar
Mark Otto committed
687
      <th scope="row">1</th>
688
689
690
691
692
693
694
695
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
696
      <th scope="row">2</th>
697
698
699
700
701
702
703
704
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
    </tr>
    <tr>
Mark Otto's avatar
Mark Otto committed
705
      <th scope="row">3</th>
706
707
708
709
710
711
712
713
714
715
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
      <td>Table cell</td>
    </tr>
  </tbody>
</table>
{% endexample %}